Sharing an Object
Scenarios
You can share temporary URLs of your objects with others for them to access your objects stored in OBS.
Background Information
You can share files with other users temporarily or permanently.
- Temporary sharing:
Share a file to other users through the temporary URL of the file. File sharing is temporary. All sharing URLs are only valid for a limited period of time.
A temporary URL consists of the access domain name and the temporary authentication information of a file. Example:
https://bucketname.obs.ap-southeast-1.myhuaweicloud.com:443/image.png?AccessKeyId=xxx&Expires=xxx&x-obs-security-token=xxx&Signature=xxx
The temporary authentication information contains the AccessKeyId, Expires, x-obs-security-token, and Signature parameters. AccessKeyId, x-obs-security-token, and Signature are used for authentication. The Expires parameter specifies the validity period of the authentication.
For details about the temporary authentication method and parameters, see Authentication of Signature in a URL in the Object Storage Service API Reference.
- Permanent sharing:
If you set the permission for an object to allow anonymous users to read it, anonymous users can access the object through the URL that you shared. For details about how to configure permissions, see Granting Public Read Permissions on Objects to Anonymous Users.
The method of using a browser to access objects varies depending on the object type. You can directly open .txt and .html files using a browser. However, when you open .exe and .dat files using a browser, the files are automatically downloaded to your local computer.
For details about how to obtain the object access URL, see How Do I Obtain the Access Path to an Object?
If access to an object using the URL fails, fix the problem by referring to Why Can't I Access an Object Through Its URL?
Limitations and Constraints
- An authorization code is not required for temporarily sharing a file. Temporarily sharing a folder requires an authorization code when the method of sharing by access code is used. For details, see Sharing a Folder.
- The following table describes the URL validity period of the files that are temporarily shared in different ways.
Way
URL Validity Period
OBS Console
The URL is valid for 1 minute to 18 hours.
After an object is shared, the system will generate a URL that contains the temporary authentication information, valid for five minutes since its generation by default. Each time you change the validity period of a URL, OBS obtains the authentication information again to generate a new URL for sharing. The new URL becomes valid at the moment the validity period is changed.
If you need a longer validity period, use OBS Browser+ that allows a validity period of up to one year to share the object. If you want a shared object to be permanently valid, use a bucket policy to grant anonymous users the read-only permission for the object.
SDKs
Configure parameter Expires to specify when a temporary authorization expires. The temporary authorization expires in 20 years in maximum.
API
Configure parameter Expires to specify when a temporary authorization expires. The temporary authorization expires in 20 years in maximum.
OBS Browser+
When you log in to OBS Browser+ using an account and password, a shared URL can be valid for 24 hours at most. The default validity period is 10 hours.
If a longer validity period is required, use the permanent AK/SK for login.
obsutil
Use the additional parameter e to specify when an object download URL expires. The minimum value is 60s and the default one is 300s. There is no upper limit on the expiration time.
- Only buckets of version 3.0 support object sharing. For details about how to query the bucket version, see Checking OBS Version (OBS 2.0 or OBS 3.0).
- Archive objects can be shared only after they have been restored.
- Deep Archive objects can be shared only after they have been restored.
- Object sharing is available in all regions except CN Southwest-Guiyang1.
Ways to Share an Object
You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to share an object.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot