How do I perform a multipart upload?

The Upload API supports 3 ways to upload a file:

  1. Multipart uploads (recommended for performance)
  2. Single-part binary uploads (simple)
  3. Single-part form-data uploads (simple)

Options 2 and 3 only require a single HTTP request.

Option 1 requires multiple HTTP requests.

Both Upload.js and Uploader use option 1 (multipart uploads), so if you're uploading files from the browser, we recommend using either of these libraries.

To implement multipart uploads in another language:

  1. Calculate the file's size.
  2. Call the begin multipart upload endpoint, passing the file size.
  3. Open the file for reading.
  4. Read a section of the file. (This must be the same section specified by the "inclusiveStart" and "inclusiveEnd" fields from the HTTP response from step 2 or step 10.)
  5. Make an HTTP "PUT" request, using the data from step 4 as the request body, and the "uploadUrl" from the HTTP response in step 2 / step 10 as the URL.
  6. If "uploadParts.count = 1", then add the following HTTP request headers, changing image/jpeg and example.jpg as necessary. (If "uploadParts.count > 1", add no additional request headers.)
    Content-Type: image/jpeg
    Content-Disposition: inline; filename="example.jpg"; filename*=UTF-8''example.jpg
    	
  7. Read the "etag" HTTP response header from step 5.
  8. Call complete upload part, passing the "etag", "fileId", and "uploadPartIndex".
  9. If "uploadPartIndex = uploadParts.count - 1", then exit (the upload is complete), else continue:
  10. Call get upload part, passing an incremented "uploadPartIndex".
  11. Repeat from step 4, using the "uploadPartIndex", "uploadUrl", "inclusiveStart", and "inclusiveEnd" returned by step 10.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us