API - Upload a file

In this chapter we'll learn how to upload file. Uploading file using API is multi-step process.

  1. Initiate a group transfer
  2. Initiate a file transfer
  3. Upload a file
  4. Complete a file transfer
  5. Complete a group transfer

Initiate group transfer

You can upload multiple files in single group upload. To initiate group transfer use GET/vault_rest/transfer``endpoint. Here is an example:

Powershell
Response
Copy

Initiate file transfer

Now we'll create empty file on server where we'll stream data from our local file. for that we use GET /vault_rest``/transfer_fileendpoint. We need to send some essential data with headers.

  • transfer_method – Method used for transferring the file as Binary data either Stream or Chunk.
  • group_id – The transfer group ID.
  • file_size – Size of the file in bytes.
  • file_name – Name of the file to be uploaded. (Example: Testing image 2.png → Testing image 2)

For larger files, this method may cause issues due to size limitations. In such cases, you should upload the file in chunks (typically 10MB per chunk). To enable chunked upload, make sure to include the chunk_offset header in your request.

Powershell
Response
Copy

Upload a file

For uploading file we'll use PATCH/vault_rest/transfer_file endpoint. For this transfer we need to sed some headers:

  • group_id – The group transfer ID received from the Initialize Group Transfer step
  • file_id – The file ID received from the Initialize File Transfer step
Powershell
Response
Copy

Complete file transfer

For uploading file we'll use POST/vault_rest/transfer_file endpoint. For this transfer we need to sed some headers:

  • group_id – The group transfer ID received from the Initialize Group Transfer step
  • file_id – The file ID received from the Initialize File Transfer step
Powershell
JSON
Copy

Complete group transfer

For uploading file we'll use POST/vault_rest/transfer endpoint. For this transfer we need to sed some headers:

  • group_id – The group transfer ID received from the Initialize Group Transfer step
Powershell
JSON
Copy

Conclusion

Process described in this document will upload one smaller file. To upload more files, repeat steps 2, 3, 4 for each file. In case of bigger files upload file in more chunks of around 10MB by repeating step 3.

Whole example

Here is whole ting on one place. Make sure to change configuration variable at the beginning of the code.

Powershell
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard