Normal Upload

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

Description

This interface provides the capability of uploading a resource file to a specified bucket on the cloud storage platform. If the size of a file is larger than 500MB, multipart upload must be used.
Normal Upload also supports to upload through HTML form.

NOTE:

  1. The recommended size of a file for multipart upload varies by the environment. Please refer to the recommended values given in the relevant SDK.
  2. The upload domain name provided by the cloud storage is an ordinary domain name.

Request Description

Upload requests are organized through HTTP request forms, i.e., multipart/form-data


    POST /file/upload HTTP/1.1
    Host: <UploadDomain>
    Accept: */*
    Content-Type: multipart/form-data; boundary=<boundary>
    Content-Length: <multipartContentLength>
    --<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="original file name"
    Content-Type: application/octet-stream
    <fileBinaryData>
    --<boundary>--

Header Description

Header Name Required Description
Host Yes Upload Domain Name, which can be obtained from the User Management Interface.
Accept Yes Type of acceptance, which is fixed as */*.
Content-Type Yes Type of content, which is fixed as multipart/form-data. <boundary> is the Multipart separator.
Content-Length Yes Total length of content, unit: Bytes.

Form Description

Parameter Required Description
<token> Yes Upload Credential
<x:VariableName> No Name of value of custom variable.
<x:VariableValue> No Value of custom variable.
<key> No Custom File Name)
<mimeType> No MIME-Type of custom file.
<deadline> No File storage life. Files that exceed the number of storage days will be deleted automatically, unit: Days. For example: 1, 2, 3...
NOTE: 0 indicates deletion as soon as possible. Configuration of 0 during file upload is not recommended
<file> Yes The file.
<fileBinaryData> Yes Binary stream of the file.

Response Description


HTTP/1.1 200 OK
    Server: WS-web-server
    <ResponseContent>

If a request is successful, will be a [URL-Safe Base64 Encoded] (#/help/details/31/3707) character string of the following content:

hash=<filehash>

Field name Required Description
<filehash> Yes The file’s hash value.

NOTE: If returnBody is defined at the time of the upload, the content of returnBody will be added to the returned content, such as name=&size=hash=.

If a request fails, will be a JSON character string of the following content:


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

Field name Required Description
code Yes HTTP request response code. Refer to the [HTTP Response Status Codes] (#/help/details/31/3705)
message Yes Prompt message.

Example


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