You can configure a symbolic link to point to a frequently accessed object in the target bucket for easier object retrieval. After configuring a symbolic link for an object, you can use the symbolic link to quickly access the object. A symbolic link works in a similar manner as the shortcut in Windows. This topic describes how to manage symbolic links in a versioning-enabled bucket.

Create a symbolic link

A symbolic link can have multiple versions. When you create a symbolic link in a versioning-enabled bucket,the version ID of the link is automatically generated by OSS and is returned as the x-oss-version-id header in the response. You can create a symbolic link and point it to the current version of the target object.
Note In a versioning-enabled bucket, a symbolic link cannot be created for a delete marker.

The following code provides an example on how to create a symbolic link:

using Aliyun.OSS;
var endpoint = "<yourEndpoint>";
var accessKeyId = "<yourAccessKeyId>";
var accessKeySecret = "<yourAccessKeySecret>";
var bucketName = "<yourBucketName>";
var targetObjectName = "<yourTargetObjectName>";
var symlinkObjectName = "<yourSymlinkObjectName>";
var objectContent = "More than just cloud." ;
// Create an OSSClient instance.
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try
{
    // Upload the target object.
    byte[] binaryData = Encoding.ASCII.GetBytes(objectContent);
    MemoryStream requestContent = new MemoryStream(binaryData);
    client.PutObject(bucketName, targetObjectName, requestContent);
    // Create the symbolic link.
    client.CreateSymlink(bucketName, symlinkObjectName, targetObjectName);
}
catch (Exception ex)
{
    Console.WriteLine("Failed with error info: {0}", ex.Message);
}

For more information about how to create a symbolic link, see PutSymlink.

Obtain symbolic links

By default, GetSymlink obtains the current version of the target symbolic link. You can specify the version ID in the request to obtain the specified version of a symbolic link. If the current version of the target symbolic link is a delete marker, OSS returns the 404 Not Found error and includes oss-delete-marker = true and x-oss-version-id in the response header.
Note You must have the read permission on a symbolic link to obtain it.

The following code provides an example on how to obtain a symbolic link:

using Aliyun.OSS;
var endpoint = "<yourEndpoint>";
var accessKeyId = "<yourAccessKeyId>";
var accessKeySecret = "<yourAccessKeySecret>";
var bucketName = "<yourBucketName>";
var symlinkObjectName = "<yourSymlinkObjectName>";
var versionid = "<yourArchiveObjectVersionid>";
// Create an OSSClient instance.
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try
{
    // Obtain the name of the object to which the symbolic link points.
    var request = new GetSymlinkRequest(bucketName, symlinkObjectName)
    {
        // Obtain the specified version of a symbolic link.
        VersionId = versionid
    };
    var ossSymlink = client.GetSymlink(request);
    Console.WriteLine("Target object is {0}", ossSymlink.Target);
}
catch (Exception ex)
{
    Console.WriteLine("Failed with error info: {0}", ex.Message);
}

For more information about how to obtain a symbolic link, see GetSymlink.