Modern Stack File Upload

Prepare the upload

Prepare the upload of a file in chunks.

post
https://example.com/v7/file_cmds/upload/prepare

Body

application/json
object

Response

application/json

Successful response

file_idstring

File ID to be used in subsequent upload steps.

Example:00000000-0000-0000-0000-000000000000

post/v7/file_cmds/upload/prepare

Body

{}
 
application/json

Step 2

This endpoint uploads a chunk of the file. You need to provide the file ID obtained from the prepare upload step and the chunk number (starting from 0). The request body should contain the binary data of the chunk being uploaded.

Upload a file chunk

Upload a chunk of the file.

post
https://example.com/v7/file_cmds/upload/{file_id}/chunk/{chunk_number}

Path Parameters

file_idstringrequired

The file ID retrieved from the prepare upload step.

Example:00000000-0000-0000-0000-000000000000

chunk_numberintegerrequired

The number of the chunk being uploaded. The first chunk is 0.

Headers

Content-Typeenumrequired

Allowed values:application/octet-stream

Content-SHA256stringrequired

(calculated checksum of the file/ chunk)

Example:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Body

application/octet-stream
string(binary)

Response

Chunk uploaded successfully

post/v7/file_cmds/upload/{file_id}/chunk/{chunk_number}

Body

No file selected
 

Step 3

This endpoint finalizes the upload after all chunks have been uploaded. You need to provide the file ID and details about the file, including its name, size, and the number of chunks it was split into.

Finalize the upload

Finalize the upload after all chunks have been uploaded.

post
https://example.com/v7/file_cmds/upload/{file_id}/finalise_api

Path Parameters

file_idstringrequired

The file ID retrieved from the prepare upload step.

Example:00000000-0000-0000-0000-000000000000

Body

application/x-www-form-urlencoded
chunksCountinteger

Number of chunks the file was split into.

Example:1

fileNamestring

Filename of the file.

Example:image.jpeg

fileSizeinteger

Size of the file in bytes.

Example:63973541

Response

Upload finalized successfully

post/v7/file_cmds/upload/{file_id}/finalise_api

Body

{}