You can run the read-symlink command to query information about a symbolic link, including the ETag and last modified time. To run this command to query information about a symbolic link, you must have read permissions on the symbolic link.
Usage notes
To query symbolic links, you must have the oss:GetObject permission. For more information, see Attach a custom policy to a RAM user.
This topic provides sample command lines that are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil command reference.
For more information about symbolic links, see Create symbolic links.
Command syntax
./ossutil64 read-symlink oss://bucketname/objectname [--encoding-type <value>] [--payer <value>]
The following table describes the parameters and options in the syntax.
Parameter/Option | Description |
bucketname | The name of the bucket. |
objectname | The name of the symbolic link you want to query. |
--encoding-type | The method that is used to encode the name of the symbolic link. Valid value: url. If you do not specify this option, the name is not encoded. |
--payer | The payer of the traffic and request fees. If you want the requester who accesses the resources in the specified path to pay the traffic and request fees, set this option to requester. |
Examples
The following command queries information about a symbolic link named test.jpg in a bucket named examplebucket.
./ossutil64 read-symlink oss://examplebucket/test.jpg
The following output indicates that the information about test.jpg is obtained, including the ETag value, last modified time, and the object to which the symbolic link points. According to the output, test.jpg points to an object named example.jpg.
Etag : 938F26218CE422CBEEE0B6543A2B2D
Last-Modified : 2021-04-21 18:00:13 +0800 CST
X-Oss-Symlink-Target : example.jpg
0.217317(s) elapsed
If you run the command to query an object that is not a symbolic link, NotSymlink
is returned.
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, you can 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 query information about a symbolic link named testobject.png in the testbucket bucket that is located in the China (Shanghai) region and owned by another Alibaba Cloud account:
./ossutil64 read-symlink oss://testbucket/testobject.png -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA**** -k 67DLVBkH7EamOjy2W5RVAHUY9H****
For more information about common options, see Common options.