Append Upload

最終更新日:2022-03-01 18:00:52

Description

The append upload interface allows users to append content directly to an object, with each append upload data instantly readable. The object operated in this manner is called an Appendable object.

Request Description

Token calculation and upload policy definition are consistent with common upload interfaces. Each append operation is performed according to normal upload policy.

Request style

POST /append/<position>
Host: <UploadDomain>
Content-Length:<appendSize>
Content-Type: multipart/form-data; boundary=<boundary>

--<boundary>
Content-Disposition: form-data; name="token"

<uploadToken>
--<boundary>
Content-Disposition:       form-data; name="<x:VariableName>"

<x:VariableValue>
--<boundary>
Content-Disposition: form-data; name="key"
    
<key>
--<boundary>
Content-Disposition: form-data; name="mimeType"
    
<mimeType>
--<boundary>
Content-Disposition: form-data; name="deadline"
    
<deadline>
--<boundary>
Content-Disposition: form-data; name="file"; filename="原文件名"
Content-Type: application/octet-stream
    
<fileBinaryData>
--<boundary>--

Request message parameters

Parameter name Description Required
append Indicating the way of append upload. yes
position Indicating where to append and size of appendable object. yes

Request Headers

Header name Required Description
Host yes Upload domain name, available in the user management interface.
Content-Length yes Length of append content
Content-Length yes Standard MIME type.
Type: string.
Fixed value: multipart/form-data.

Form description

Parameters Required Description
<token> yes Upload Credentia
<x:VariableName> no Value name of custom variable.
<key> no Custom filename
<mimeType> no Custom file MIME-Type.
<deadline> no File retention days. File exceeding retention days to be automatically deleted, unit: day. e.g., 1, 2, 3…
Note: 0 for delete asap, not recommended for file uploading.
<file> yes File itself
<fileBinaryData> yes binary stream of file.

Response Description

Response style

HTTP/1.1 status_code
x-wcs-next-append-position:object size
x-wcs-object-type:Appendable
Server: WS-web-server
<ResponseContent>

Response headers

Header name Required Description
x-wcs-next-append-position yes Indicating position of next append.
String.
x-wcs-object-type yes Indicating type of object, Appendable for appendfromfile, Normal for non-Appendable.
Type: string.

Response body
If Request successes, <ResponseContent> will be the following URL-Safe Base64 Encoding:

hash=<filehash>

Field name Required Description
<filehash> yes File hash value.

Note: if returnBody defined during uploading, returnBody will be added, for example, name=&size=hash=.
If Request fails, <ResponseContent> will be the following Json string:

{
    "code":     "<code string>",
    "message":  "<message string>"
}

Field name Required Description
code yes HTTP request response code, see HTTP Response Status Code
message yes Prompting message.

Detail Analysis

  1. URL parameter must contain append to indicate an append operation.
  2. URL parameter must contain position to indicate where to append. Position for first append operation must be 0, position for subsequent append operations must be current length of Object, or 409 is returned, with error code PositionNotEqualToLength. Upon above error, user can get next position by responding to header X-wCs-next-append-position and request again.
  3. When position is 0, if without appendable object in the same name, or length of the same-name appendable object is 0, the request is successful, and other cases will return PositionNotEqualToLength.
  4. Length of append object each time cannot exceed 2G, append object will update last revision time of object each time.
  5. Appending content with a length of 0 to an existing appendable object with correct position, the operation will be successful but not change object status.
  6. It is not allowed to append an object concurrently during append operation.
  7. The append operation requires write permission on the Object to be operated.

Example

curl -v -i -X POST -H "Expect:" -F file=@D:/8.png -F key=m.png -F token="6a69ab4062cb03059e4c13a0f5e662523effad49:ZGE1MWY1YzA4ZDgyMjVlM2Q3MmE2YjZkZDI3MmY1ZmMxNjk2YTFjOA==:eyJzY29wZSI6InRlc3QiLCJkZWFkbGluZSI6IjE0NzIxNzY2MzQwMDAiLCJvdmVyd3JpdGUiOjAsImZzaXplTGltaXQiOjAsImluc3RhbnQiOjAsInNlcGFyYXRlIjowfQ=="  --url http://uploaddomain.com/append/0