Uploading files with the File Storage API
The Apideck File Storage API supports two ways to upload files. The direct file upload API supports files up to 100MB in size and sends all the binary file data in a single API call.
The upload sessions API allows you to upload files of any size in parts. Note that some file storage connectors have their own limits.
Note π¨
File upload API calls use
https://upload.apideck.comas the base URL.
Direct upload
To upload a file via direct upload, make an API call to theΒ POST /file-storage/files
endpoint with the content of the file, the file
nameand
parent_folder_id.
Request body
The request body should be the raw binary content of the file. Do not use form data.
File metadata
Provide the file's
nameand
parent_folder_idas JSON in the
x-apideck-metadataheader.
Upload sessions
The upload sessions API requires you to make multiple API calls:
1. Create upload session
To create an upload session, make an API call to theΒ POST /file-storage/upload-sessions
endpoint with the file
name, file
sizeand
parent_folder_id.
2. Get upload session
After creating an upload session, make an API call to GET /file-storage/upload-sessions/ID
. Use the ID you received after creating the upload session.
3. Upload parts of file
Use the
part_sizefrom the previous step to split the file to be uploaded into parts. You can use the split command to do this:
Upload the parts in sequence to the PUT /file-storage/upload-sessions/ID
endpoint. Send a valid
part_numberwith each request (
part_numberstarts at 0). Always provide valid
Content-Typeand
Content-Lengthheaders. If you are unsure of the content type of the uploaded file, use
application/octet-stream.
Note π¨
For the Box connector it is required to send a
Digestheader with a hash of the partβs contents. More info in the Box API documentation
here
4. Finish upload session
The final step is to finish the session using the POST /file-storage/upload-sessions/ID/finish
endpoint. The result of the API call is a complete File resource.
Note π¨
For the Box connector it is required to send a Digest header with a hash of the whole fileβs contents. More info in the Box API documentation
here
FAQ and troubleshooting
What happens if I upload image.png but image.png already exists?
When there is a conflict (file with same name), these are behaviors that can happen:
- Autorename: renames file (image (2).png)
- Replace: silently replaces the current file
- Error: returns an error
- New: creates a new file with the same name (files are not unique by name)
When mapping these behaviors to the integrations, we end up with this matrix:
Connector | Autorename | Replace | Error | New |
---|---|---|---|---|
Dropbox | β | βοΈ | βοΈ | π΄ |
Box | π΄ | π΄ | β | π΄ |
OneDrive | βοΈ | β | βοΈ | π΄ |
SharePoint | βοΈ | β | βοΈ | π΄ |
Google Drive | π΄ | π΄ | π΄ | β |
- β Supported by the integration and supported by Unify
- βοΈ Supported by the integration but not supported by Unify at this moment
- π΄ Not supported by the integration
The different integrations have different behaviors for handling conflicts with files. Because of these differences it is not possible to "unify" the way handling of duplicate/conflict files, because there is no behavior that is supported for all connectors. Error comes closest, only Google Drive doesn't support it.