The symbolic link feature provides a convenient way to access frequently used objects in a bucket. After you create a symbolic link, you can use it to access an object, similar to a shortcut in Windows. This topic describes how to use the OSS SDK for Python to create and obtain symbolic links.
Precautions
The sample code in this topic uses the China (Hangzhou) region (
cn-hangzhou) as an example. It uses a public endpoint by default. If you access OSS from another Alibaba Cloud service in the same region, use an internal endpoint. For more information about the regions and endpoints that OSS supports, see OSS regions and endpoints.To create a symbolic link, you must have the
oss:PutObjectpermission. To obtain a symbolic link, you must have theoss:GetObjectpermission. For more information, see Grant custom permissions to a RAM user.
Method definitions
Create a symbolic link
put_symlink(request: PutSymlinkRequest, **kwargs) → PutSymlinkResultObtain a symbolic link
get_symlink(request: GetSymlinkRequest, **kwargs) → GetSymlinkResultRequest parameters
Parameter | Type | Description |
request | PutSymlinkRequest | The request parameters to create a symbolic link. For more information, see PutSymlinkRequest |
GetSymlinkRequest | The request parameters to obtain a symbolic link. For more information, see GetSymlinkRequest |
Return values
Type | Description |
PutSymlinkResult | The return value. For more information, see PutSymlinkResult |
GetSymlinkResult | The return value. For more information, see GetSymlinkResult |
For the complete definition of the method to create a symbolic link, see put_symlink.
For the complete definition of the method to obtain a symbolic link, see get_symlink.
Sample code
References
For the complete sample code for creating a symbolic link, see put_symlink.py.
For the complete sample code for obtaining a symbolic link, see get_symlink.py.