A symbolic link provides quick access to an object in a bucket and facilitates access to a frequently used object. Symbolic links in Object Storage Service (OSS) work like file shortcuts on Windows and allow you to quickly access associated objects. This topic describes how to configure and query symbolic links using OSS SDK for Go.
Notes
The sample code in this topic uses the region ID
cn-hangzhou
of the China (Hangzhou) region. By default, the public endpoint is used to access resources in a bucket. If you want to access resources in the bucket by using other Alibaba Cloud services in the same region in which the bucket is located, use an internal endpoint. For more information about the regions and endpoints supported by Object Storage Service (OSS), see OSS regions and endpoints.In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials.
Creating symbolic links requires the
oss:PutObject
permission, while querying symbolic links requires theoss:GetObject
permission. For more information, see Grant custom policy to RAM users.
Methods
Configure symbolic links
func (c *Client) PutSymlink(ctx context.Context, request *PutSymlinkRequest, optFns ...func(*Options)) (*PutSymlinkResult, error)
Query symbolic links
func (c *Client) GetSymlink(ctx context.Context, request *GetSymlinkRequest, optFns ...func(*Options)) (*GetSymlinkResult, error)
Request parameters
Parameter | Type | Description |
ctx | context.Context | The context of the request, which can be used to specify the total duration of the request. |
request | *PutSymlinkRequest | The request parameters for configuring symbolic links. For details, see PutSymlinkRequest |
*GetSymlinkRequest | The request parameters for querying symbolic links. For details, see GetSymlinkRequest | |
optFns | ...func(*Options) | Optional. The operation-level parameter. For more information, see Options. |
Return values
Value | Type | Description |
result | *PutSymlinkResult | Return values for configuring symbolic links. This parameter is valid when the value of err is nil. For more information, see RestoreObjectResult. |
*GetSymlinkResult | Return values for querying symbolic links. This parameter is valid when the value of err is nil. For more information, see GetSymlinkResult. | |
err | error | The status of the request. If the request fails, the value of err cannot be nil. |
Sample code
References
For the complete sample code that is used to manage symbolic links, visit put_symlink.go and get_symlink.go.
For more information about related operations, see Symbolic Links.
For more information about the API operation that you can call to configure symbolic links, visit PutSymlink.
For more information about the API operation that you can call to query symbolic links, visit GetSymlink.