A symbolic link provides quick access to objects in a bucket and is similar to a shortcut in Windows. After you create a symbolic link using the create-symlink command, you can use the symbolic link to quickly access the source object file.
Usage notes
-
To create a symbolic link, you must have the
oss:PutObjectpermission. For more information, see Attach a custom access policy to a RAM user.
-
For ossutil 1.6.16 and later, you can use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. If your ossutil version is earlier than 1.6.16, you must update the binary name based on the operating system. For more information, see ossutil command reference.
Command syntax
ossutil create-symlink cloud_url target_object
[--encoding-type <value>]
[--payer <value>]
The following table describes the parameters and options.
|
Configuration Item |
Description |
|
cloud_url |
The full path of the bucket that contains the symbolic link file. |
|
target_object |
The full path of the object to which the symbolic link points. The symbolic link and the target object must be in the same bucket. |
|
--encoding-type |
The encoding type of the object names in |
|
--payer |
The payment method for the request. To specify that the requester pays for fees such as traffic and the number of requests, set this option to requester. |
Examples
This command does not check whether the target object exists when you create a symbolic link. If the target object exists, you can access the object using the symbolic link. If the target object does not exist, you cannot access the object using the symbolic link. If you are not sure whether the target object exists, you can run the ls command to list all objects in the target bucket.
The following examples show how to create a symbolic link for an existing object:
If the name of the new symbolic link is the same as an existing symbolic link, the existing symbolic link is overwritten.
-
Create a symbolic link named test.jpg in the root directory of the examplebucket bucket that points to the exampleobject.jpg object in the same directory.
ossutil create-symlink oss://examplebucket/test.jpg oss://examplebucket/exampleobject.jpg -
Create a symbolic link named example.jpg in the destfolder directory of the examplebucket bucket. The symbolic link points to the test.jpg object in the root directory of the bucket. The requester pays for the fees.
ossutil create-symlink oss://examplebucket/destfolder/example.jpg oss://examplebucket/test.jpg --payer requester -
The following output indicates that the symbolic link is created.
0.106744(s) elapsedAfter the symbolic link is created, you can run the read-symlink or stat command to obtain information about the symbolic link, such as its ETag value and last modified time.
Common options
To access a bucket in a different region, use -e to specify the endpoint. To access a bucket owned by a different Alibaba Cloud account, use -i for the AccessKey ID and -k for the AccessKey secret.
For example, the following command creates a symbolic link named testobject.png for the exampleobject.png object. The object is in the testbucket bucket, which is in the China (Shanghai) region and belongs to another Alibaba Cloud account.
ossutil create-symlink oss://testbucket/testobject.png oss://testbucket/exampleobject.png -e oss-cn-shanghai.aliyuncs.com -i yourAccessKeyID -k yourAccessKeySecret