更新时间:2022-03-01 18:00:48
Place the upload credential in the request form; parameter name: token
.
The three underlying data sources for constructing the upload credential are as follows:
(putPolicy)
(SecretKey)
(AccessKey)
The upload credential uploadToken
is the result of a complex signature calculation based on the three underlying data sources. By verifying the upload credential, we can ensure that illegal upload requests are blocked and illegal intrusions are prevented.
{
“scope”: “”,
“deadline”: “”,
“saveKey”: “”
“returnUrl”: “”,
“returnBody”: “”,
“overwrite”: “”,
“fsizeLimit”: “”,
“callbackUrl”: “”,
“callbackBody”: “”,
“persistentOps”: “”,
“persistentNotifyUrl”: “”
“contentDetect”: “”
“detectNotifyURL”: “”
“detectNotifyRule”:""
“separate”: “”
}
Field name | Required | Description |
---|---|---|
scope | Yes | Specifies the destination bucket <bucket> of the upload and the file name<key> . There are two formats: a. <bucket> indicates the uploading of a file to the specified bucket. b. <bucket>:<key> indicates the uploading of a file to the specified bucket, where the file is named as key. When overwrite is 1, the same-name resource (if existing) will be overwritten. |
deadline | Yes | The deadline for upload request authorization; UNIX timestamp; unit: millisecond. Example: 1398916800000, indicating the time of 2014-05-01 12:00:00. |
saveKey | No | Custom Resource Name. This field only supports the normal upload method. |
fsizeLimit | No | Limits the size of the upload file; unit: Byte. Upload of any file larger than the size limit will fail, and a 401 status code will be returned. NOTE: No limit is in place when this item is set to 0 |
overwrite | No | Specifies whether or not to overwrite a file that already exists on the server: 0 - Do not overwrite, 1 - Overwrite. 0 by default. |
returnUrl | No | When a file is uploaded from a web end, the browser will execute the URL redirected by a 303. This is often used for HTML Form uploads. If the file has been uploaded successfully, the redirection points to <returnUrl>?upload_ret=urlsafe_base64_encode(returnBody) . If the file upload has failed, the redirection points to <returnUrl>?code=<code>&message=<message> , where <code> is the error code and <message> is specific information on the error. If returnUrl is not set, the content of returnBody will be returned straight to the client. |
returnBody | No | Customizes data that will ultimately be returned to the upload end upon a successful upload. If you only need to return the file name and file address, just set returnBody as fname=$(fname)&url=$(url) . For details on the usage, see the Returned Data Description. |
callbackUrl | No | Upon a successful upload, the cloud storage requests the address with the POST method. (Requirement: The address must be a public network URL address that can respond normally with HTTP/1.1 200 OK. If there are special characters like spaces, Url Encode encoding is required.) The response data for this address is in JSON format. |
callbackBody | No | Upon a successful upload, CDNetworks cloud submits data to callbackUrl with the POST method.callbackBody must be a legal url query string , for example: key=$(key)&fsize=$(fsize) . For details on the usage, see the Callback Method Data Description |
persistentNotifyUrl | No | The address for receiving the preprocessing result notification must be a public network URL address that can respond normally with HTTP/1.1 200 OK. If there are special characters like spaces, Url Encode encoding is required. For details on the content of the notification, see the Notification Data Content Description |
persistentOps | No | Preprocesses the instruction list upon successful upload of a file. Each instruction is an API-specification character string. The semicolon, ; , is used to separate multiple instructions. See the Instruction Description. |
contentDetect | No | Performs the content identification operation upon the successful upload of a file. Parameters supported: imagePorn - porn identification for images, imageTerror - terrorism identification for images, imagePolitical - politician identification |
detectNotifyURL | No | The address for receiving the identification result notification must be a public network URL address that can respond normally with HTTP/1.1 200 OK. If there are special characters like spaces, Url Encode encoding is required. For details on the content of the notification, see the Identification Notification Data Content Description |
detectNotifyRule | No | Sets identification result notification rules. all Notification on all images porn Notification on pornographic images sexy Notification on sexy images normal Notification on normal images exception Notification on images identified as exceptions terror Notification on violent and terrorism images(Valid only when the identification type is imageTerror) political Notification on identification of images of politicians (Valid only when the identification type is imagePolitical) Parameters can be combined with each other and separated by the semicolon For example: When the parameter is set as porn;exception, the notification on the results of the identification will be pornographic images or images identified as exceptions |
separate | No | Whether or not there are separate transcoding notifications. Set 1 and 0 as option codes: 1: Indicates that persistentNotifyUrl is notified upon completion of the execution of each transcoding instruction 0: Indicates that persistentNotifyUrl is notified in one go upon completion of the execution of all transcoding instructions The default value is 0 |
NOTE:
Use the JSON format to encapsulate some information of the uploaded file putPolicy
{
"scope": "<bucket string>",
"deadline": "<deadline string>",
"returnBody": "<returnBody string>",
"overwrite": "<overwrite int>",
"fsizeLimit": "<fsizeLimit long>",
"returnUrl": "<returnUrl string>"
}
Perform URL-Safe Base64 Encoding for putPolicy
to obtain encodePutPolicy
encodePutPolicy = urlsafe_base64_encode(putPolicy)
Use SecretKey
to provide HMAC-SHA1
signature for encodePutPolicy
to obtain Sign
Sign = hmac_sha1(encodePutPolicy, “
”)
External resource: HMAC-SHA1 Signature
Sample code: HMAC-SHA1 Signature
Perform URL-Safe Base64 Encoding for the signature data Sign to obtain encodedSign
encodeSign = urlsafe_base64_encode(Sign)
Join AccessKey, encodedSign and encodeputPolicy together using : to obtain the upload credential uploadToken
uploadToken = AccessKey:encodedSign:encodePutPolicy