Skip to content

Latest commit

 

History

History
95 lines (73 loc) · 3.06 KB

file-version.md

File metadata and controls

95 lines (73 loc) · 3.06 KB
rank related_endpoints related_guides related_pages required_guides related_resources alias_paths
2
options_files_id_content
post_files_id_content
uploads/check

Upload File Version

To upload a new version of a file to Box via direct upload, make an API call to the POST /files/:id/content API with the content of the file, the desired file name, and the folder ID.

# Preflight check

To prevent wasting time and bandwidth uploading a file that is going to be rejected it is recommended to perform a pre-flight check before uploading the file.

Request Format

The request body of this API uses a content type of multipart/form-data. This is used to transmit two parts, namely the file attributes and the file's actual content.

The first part is called attributes and contains a JSON object with information about the file, including the name of the file and the id of the parent folder.

The following is an example a test.txt being uploaded to the root folder of the user.

POST /api/2.0/files/123/content HTTP/1.1
Host: upload.box.com
Authorization: Bearer [ACCESS_TOKEN]
content-length: 343
content-type: multipart/form-data; boundary=------------------------9fd09388d840fef1

--------------------------9fd09388d840fef1
content-disposition: form-data; name="attributes"

{"name":"test.txt", "parent":{"id":"0"}}
--------------------------9fd09388d840fef1
content-disposition: form-data; name="file"; filename="test.txt"
content-type: text/plain

Test file text.

--------------------------9fd09388d840fef1--
The `attributes` JSON part of the multi-part body must come before the `file` part of the multipart form data. When out of order, the API will return a HTTP `400` status code with an error code of `metadata_after_file_contents`.

Options

To learn more about all the parameters available when uploading files, head over to the reference documentation for this API call. These parameters include a content-md5 that can be set to ensure a file is not corrupted in transit, and the ability to explicitly specify the file creation time at a different time than the upload time.

For file versions an additional if-match header can be passed along to prevent overwriting a file that has already been updated since the application last inspected the content.

Restrictions

Direct uploads are limited to a maximum file size of 50MB. For larger files, please use the chunked upload APIs.

Upload limits are dictated by the type of account of the authenticated user. More information can be found in our community article on this topic.