Creating a Signed URL
API Description
You can use this API to generate a URL whose Query parameter is carried with authentication information, by specifying the AK and SK, HTTP method, and request parameter. You can use a signed URL to perform specific operations on OBS.
Method Definition
ObsClient.createSignedUrlSync
Request Parameter
|
Field |
Type |
Optional or Mandatory |
Description |
|---|---|---|---|
|
Method |
String |
Mandatory |
HTTP method. Possible values are:
|
|
Bucket |
String |
Optional |
Bucket name |
|
Key |
String |
Optional |
Object name |
|
SpecialParam |
String |
Optional |
Special operator, which indicates the sub-resource to access. For details, see Table 2. |
|
Expires |
Number |
Optional |
Expiration time of the signed URL, in seconds. The default value is 300. |
|
Headers |
Object |
Optional |
Headers in the request |
|
QueryParams |
Object |
Optional |
Query parameters in the request |
|
Constant |
Applicable API |
|---|---|
|
storagePolicy |
Specify or obtain bucket storage classes. |
|
quota |
Specify or obtain bucket quotas. |
|
storageinfo |
Obtain bucket storage information. |
|
location |
Obtain bucket locations. |
|
acl |
Specify or obtain bucket ACLs or object ACLs. |
|
policy |
Specify, obtain, or delete bucket policies. |
|
cors |
Specify, obtain, or delete bucket CORS configurations. |
|
versioning |
Specify or obtain bucket versioning statuses. |
|
website |
Specify, obtain, or delete bucket website configurations. |
|
logging |
Specify or obtain bucket logging settings. |
|
lifecycle |
Specify, obtain, or delete lifecycle rules of buckets. |
|
notification |
Specify or obtain the notification configurations of buckets. |
|
tagging |
Specify, obtain, or delete bucket tags. |
|
delete |
Batch delete objects. |
|
versions |
List object versions in buckets. |
|
uploads |
List or initiate multipart uploads in buckets. |
|
restore |
Restore Archive objects. |
Returned Result
|
Field |
Type |
Description |
|---|---|---|
|
SignedUrl |
String |
Signed URL |
|
ActualSignedRequestHeaders |
Object |
Actual headers in the request initiated by using the signed URL |
Sample Code
// Generate a signed URL for uploading an object.
var putObjectResult = obsClient.createSignedUrlSync({Method : 'PUT', Bucket : 'bucketname', Key : 'objectkey', Headers : {'Content-Type' : 'text/plain'}});
console.log('SignedUrl-->' + putObjectResult['SignedUrl']);
console.log('ActualSignedRequestHeaders-->' + JSON.stringify(putObjectResult['ActualSignedRequestHeaders']));
// Generate a signed URL for setting an object ACL.
var setObjectAclResult = obsClient.createSignedUrlSync({Method : 'PUT', Bucket : 'bucketname', Key : 'objectkey', SpecialParam: 'acl', Headers: {'x-amz-acl' : 'public-read'}});
console.log('SignedUrl-->' + setObjectAclResult['SignedUrl']);
console.log('ActualSignedRequestHeaders-->' + JSON.stringify(setObjectAclResult['ActualSignedRequestHeaders']));
// Generate a signed URL for downloading an object.
var getObjectResult = obsClient.createSignedUrlSync({Method : 'GET', Bucket : 'bucketname', Key : 'objectkey'});
console.log('SignedUrl-->' + getObjectResult['SignedUrl']);
console.log('ActualSignedRequestHeaders-->' + JSON.stringify(getObjectResult['ActualSignedRequestHeaders']));
// Generate a signed URL for deleting an object.
var deleteObjectResult = obsClient.createSignedUrlSync({Method : 'DELETE', Bucket : 'bucketname', Key : 'objectkey'});
console.log('SignedUrl-->' + deleteObjectResult['SignedUrl']);
console.log('ActualSignedRequestHeaders-->' + JSON.stringify(deleteObjectResult['ActualSignedRequestHeaders']));
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