All Products
Search
Document Center

Object Storage Service:create-symlink

Last Updated:Aug 15, 2024

Symbolic links are similar to shortcuts in Windows and enable quick access to objects in Object Storage Service (OSS). You can run the create-symlink command to create a symbolic link that points to an object in OSS.

Usage notes

  • For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to 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 preceding parameters and options.

Parameter/Option

Description

cloud_url

The full path of the symbolic link you want to create.

target_object

The full path of the object to which the symbolic link points. A symbolic link and the object to which the symbolic link points must be in the same bucket.

--encoding-type

The method used to encode the object names specified in cloud_url and target_object. Valid value: url. If you do not specify this parameter, the names are not encoded.

--payer

The payer of the request. If you want the requester who accesses the resources in the specified path to pay the fees that are generated by the operation, such as traffic and request fees, set this parameter to requester.

Examples

When you run the create-symlink command to create a symbolic link, ossutil does not check whether the object to which the symbolic link points to exists. If the object exists, the created symbolic link points to the object. If the object does not exist, the created symbolic link points to nothing. To determine whether the object to which a symbolic link points exists, run the ls command to query all objects in the bucket.

The following examples show how to create a symbolic link that points to an existing object.

Important

If the name of the symbolic link you want to create is the same as that of an existing symbolic link in the bucket, the existing symbolic link is overwritten.

  • Create a symbolic link named test.jpg in the root directory of the examplebucket bucket and point the symbolic link to the exampleobject.jpg object in the root directory of the bucket.

    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 and point the symbolic link to the test.jpg object in the root directory of the bucket. Specify that all fees incurred when the command is run are paid by the requester.

    ossutil create-symlink  oss://examplebucket/destfolder/example.jpg  oss://examplebucket/test.jpg --payer requester
  • The following sample output indicates that the symbolic link is created for the object:

    0.106744(s) elapsed

    After the symbolic link is created, you can run the read-symlink or stat command to query the information about the symbolic link, such as the ETag value and the last update time.

Common options

If you use ossutil to switch to a bucket that is located in another region, add the -e option to the command to specify the endpoint of the region in which the specified bucket is located. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, add the -i option to the command to specify the AccessKey ID of the specified account, and add the -k option to the command to specify the AccessKey secret of the specified account.

For example, you can run the following command to create a symbolic link named testobject.png that points to the exampleobject.png object in the testbucket bucket that is located in the China (Shanghai) region and owned by another Alibaba Cloud account:

ossutil create-symlink  oss://testbucket/testobject.png  oss://testbucket/exampleobject.png -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA****  -k 67DLVBkH7EamOjy2W5RVAHUY9H****

For more information about common options, see Common options.