Upload a temporary file
File upload to temporary storage.
To upload a file, you need to generate a UUID and pass it as the hash request parameter. This will serve as the identifier of the file body.
You can upload a file either entirely or in parts. To upload it as a whole, provide theContent-Range header with the value bytes 0-[size]/[size] (for example, bytes 0-1000/1000).
For multipart upload, the file must be split into chunks. All chunks, except for the last one, must be of equal size. The chunk size must be at least 5 MB (5 242 880 bytes) and no more than 5 GB (5 368 709 120 bytes). The last chunk can be of any size.
To inform the server which chunk is being uploaded, include the Content-Range header in the request. The header follows this format: bytes [range-start]-[range-end]/[size]. For example, when uploading a file of 7 MB, you need the following headers: bytes 0-5242880/7340032 for the first 5 MB chunk and bytes 5242880-7340032/7340032 for the remaining part.
Requirements:
TheContent-Type headrer must be application/octet-stream.
The request body must contain the binary data of the file.
After uploading, the file must be initialized within 60 minutes (otherwise, it will be deleted).
Initialization methods:
- Move to directory via
/pub/v1/disk/file/move - Save in app:
- Create an app:/pub/v1/app/{namespace}/{code}/create
- Update an app:/pub/v1/app/{namespace}/{code}/{id}/update
Example request body for initialization:
{"context":{"__file":[{"name": "example.txt", "hash": "131141f6-0d89-4316-a8f1-bc816f0672ef"}]}}
Request
POST /pub/v1/disk/file/upload
Query parameters
| Parameter name | Value | Description | Additional |
|---|---|---|---|
| hash | uuid | Hash of the file that is going to be uploaded in parts |
Required |
Form parameters
| Parameter name | Value | Description | Additional |
|---|---|---|---|
| file | file | name: File |
Authorization
This request requires the use of one of following authorisation methods:
API key
Response
The following HTTP status codes may be returned:
| Status code | Description | Resource |
|---|---|---|
| 200 | OK The file is fully uploaded |
|
| 206 | Partial Content Part of the file is successfully uploaded |
|
| 400 | Bad Request The error is shown as a message that describes the problem. The error message may contain the following codes: |
|
| default | Response after one of the file parts is uploaded |
Response after one of the file parts is uploaded (Upload a temporary file) |