Sharing Token
You can call this API (described in Obtaining a Sharing Token) to obtain a temporary token. You can use this temporary token to access the file without using the access-token for authentication.
To share a token, perform the following steps:
- Obtaining a Sharing Token: obtains a temporary token.
- Viewing a Shared Object File: Use a temporary token to access the file.
Obtaining a Sharing Token
- Function
Used to obtain a temporary token. You can use this token to access files without using the access-token for authentication. The obtained token is temporary and has a validity period.
- URI
POST Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/connectors/{connector_type}/{connector_name}/sharetoken
Table 1 URI parameters Parameter
Mandatory
Type
Description
connector_type
Yes
String
Explanation
Type of a connector.
Constraints
None
Value
- obs: connector for interconnecting with OBS.
- minio: connector for connecting to MINIO.
- objectstorageproxy: object storage proxy type.
Default value
None
connector_name
Yes
String
Explanation
Name of the connector instance, that is, the connector instance name set when the connector is created.
Constraints
None
Value
None
Default value
None
- Request Parameters
Table 2 Request body parameters Parameter
Mandatory
Type
Description
shareType
Yes
Integer
Explanation
Sharing type.
Constraints
None
Value
- 0: sharing by file.
- 1: sharing by directory.
- 2: Use character arrays to indicate multiple file paths.
Default value
None
key
No
String
Explanation
Shared objects and directories.
Constraints
If the value is a directory, it must end with /.
Value
None
Default value
None
keys
No
String
Explanation
Multiple file paths.
Constraints
None
Value
None
Default value
None
timeoutInMinutes
Yes
Integer
Explanation
Validity period of the sharing, in minutes.
Constraints
None
Value
1 to 1440, that is, 1 to 1440 minutes.
Default value
None
- Response Parameters
Table 3 Response parameters Parameter
Type
Description
resCode
String
Explanation
Return code.
Value
If the request is successful, 0 is returned. For details about other error codes, see Error Codes.
resMsg
String
Explanation
Message returned.
Value
If the request is successful, "Success" is returned. In other cases, an error message is returned.
result
Object
Explanation
Returned result object. If the object contains the shareToken field, the token is a temporary token.
- Example Request
An OBS connector has been created. The connector instance name is Namespace __TestOBS. Call the following request to obtain a temporary access token for some files:
POST https://Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/connectors/obs/Namespace __TestOBS/sharetoken { "shareType": 0, "key": "a/b/c/1.txt", "keys": [ "a/b/c/2.txt", "ROMAExchange.zip", "some/dir/c.jpg" ], "timeoutInMinutes": 60 }
Users can access the file after obtaining the URL. Therefore, do not share sensitive files.
- Example Response
{ "resCode": "0", "resMsg": "Success", "result": { "shareToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJz***tOejj6NEo" } }
Record the value of shareToken for subsequent file access.
Viewing a Shared Object File
- Function
See Obtaining a Sharing Token to view the file based on the returned temporary token.
- URI
GET Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/objectstorage/viewshareobject?object=X&shareToken=Y
Table 4 URI parameters Parameter
Mandatory
Type
Description
object
Yes
String
Explanation
Full path of the file in the bucket, including the file name.
Constraints
None
Value
None
Default value
None
shareToken
Yes
String
Explanation
Temporary token returned in Obtaining a Sharing Token.
Constraints
None
Value
None
Default value
None
- Request Parameters
- Response Parameters
- Example Request
An OBS connector has been created. The connector instance name is Namespace __TestOBS. Call the following request to use the temporary access token to view the a/b/c/1.txt file in the bucket.
GET https://Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/objectstorage/viewshareobject?object=a/b/c/1.txt&shareToken=eyJhbGciOiJIUzI1NiIsInR******W8FYgXTGTAtOejj6NEo
- Example Response
test
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