All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Upload CallBack Processing

Last updated:2021-06-15 20:56:34

The following operations support upload callback processing (UCP): PUT Object, Complete Multipart Upload, and POST Object.

1. PUT Object and Complete Multipart Upload

Description

When you call the PUT Object or Complete Multipart Upload operation, you can add related callback parameters to the request to implement UCP.

After a client uploads an object and the related callback request header to KS3, KS3 uses the POST method to post JSON data to your callback URL. The JSON data is obtained by setting the variables in the x-kss-callbackbody request header that the client sends. After the user server processes the callback, {"result":true} is returned. If the callback processing fails, {"result":false} is returned, which indicates that an object fails to be uploaded. If the user server does not return any message, the KS3 server retries up to twice. The default timeout period during each retry is 3 seconds. The object is uploaded only after the KS3 server receives the {"result":true} message.
You can add the x-kss-callbackauth parameter as a header and set its value to 1 to enable callback authentication. For more information, see Callback authentication in this topic.

Request operation

You can call the same operation to send upload callback requests. For more information, see Put Object and Complete Multipart Upload.

Request parameters

No request parameter is used.

Request headers

Header Description Required
x-kss-callbackurl The callback URL. HTTP is supported. Yes
x-kss-callbackbody The callback body, which can contain custom parameters, constants, and magic variables. The custom parameters are returned by using the HEAD method. An example of the callback body can be objectKey=${key}&etag=${etag}&location=${kss-location} &uid=123.
The value of the callback body cannot contain the equal sign (=) or the ampersand (\&).
Yes
x-kss-callbackauth If you set this parameter to 1, callback authentication is enabled. For more information, see Callback authentication in this topic. No
kss-location The custom header, which starts with kss-. Custom

Magic variables

Variable Description Remarks
bucket The bucket to which the object is uploaded. The value is encoded in UTF-8.
key The name of the object. The value is encoded in UTF-8.
etag The Base64-encoded MD5 value of the object.
objectSize The size of the object. Unit: byte.
mimeType The type of the object.
createTime The time when the object was created. The value is a UNIX timestamp and is accurate to seconds, such as 1420629372.

Callback response

Response body

Operation-specific errors

None

2. POST Object

Description

When you implement a callback by using the POST method, you must add the postcallback parameter to the request to indicate that the request is a POST callback request. An example of the request can be POST /?postcallback HTTP/1.1. In addition to the postcallback parameter, the entries must contain callback-related parameters. Otherwise, the request is invalid. The interaction process with the callback server is the same as that for the callback using the PUT method. Other syntax is the same as that of the common POST requests. For more information, see Post Object.

Request operation

You can call the same operation to send upload callback requests. For more information, see Post Object.

Request parameters

Parameter Description Required
postcallback Indicates that the request is a POST callback request. Yes

Entries

Entry Description Required
x-kss-callbackurl The callback URL. HTTP(S) is supported. Yes
x-kss-callbackbody The callback body, which can contain custom parameters, constants, and magic variables. The custom parameters are returned by using the HEAD method. An example of the callback body can be objectKey={key}&etag={etag}&location=${kss-location} &uid=123.
The value of the callback body cannot contain the equal sign (=) or the ampersand (\&).
Yes
x-kss-callbackauth If you set this parameter to 1, callback authentication is enabled. For more information, see Callback authentication in this topic. No
kss-location The custom header, which starts with kss-. Custom

Magic variables

Variable Description Remarks
bucket The bucket to which the object is uploaded. The value is encoded in UTF-8.
key The name of the object. The value is encoded in UTF-8.
etag The Base64-encoded MD5 value of the object.
objectSize The size of the object. Unit: byte.
mimeType The type of the object.
createTime The time when the object was created. The value is a UNIX timestamp and is accurate to seconds, such as 1420629372.

Callback response

Response body

Operation-specific errors

When you call the POST callback method, if a required entry is not specified, a 400 error is returned. If all the required entries are specified but the non-callback POST method is used, a 400 error is also returned.

Callback authentication

If you set x-kss-callbackauth to 1 to enable authentication in a callback, the header that KS3 returns to your callback URL contains the following Authorization and x-kss-date fields. In a PUT or Complete Multipart Upload request, x-kss-callbackauth is a header. In a POST request, x-kss-callbackauth is an entry.

Authorization: ks3cbauth AKLTtxxxxx5IxxxpA7xxxxxx:FIexxyY3jGe07JxxxxxW5rBejKM=
  x-kss-date:1590132647609

In the Authorization field, ks3cbauth is set to a fixed value, AKLTtxxxxx5IxxxpA7xxxxxx is the AccessKey used for this POST request, and FIexxyY3jGe07JxxxxxW5rBejKM is the signature string calculated by using the AccessKey, the corresponding SecretKey, and the time that the server specifies. The x-kss-date field indicates the time when the callback was invoked, which is the system time of the KS3 server. The signature calculation method is similar to the calculation method for the request signature V2 but is simplified.

signString = "ksscallback " + {timestamp} // Example: ksscallback 1590132647609. A space exists between ksscallback and the timestamp. ksscallback is set to a fixed value.  
  signature = Base64(HMAC-SHA1(YourSecretKey, UTF-8-Encoding-Of(signString)));  
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback