1. HTTP (Hypertext Transfer Protocol)

  1. HTTP resumable uploads
    1. Option: PATCH with a segmented upload media type
    2. Option: POST with 201 Accepted response
    3. Option: Expect header with Range header
    4. Option: URI query parameter
      1. URI Template
    5. References

HTTP resumable uploads

Also called multi-part uploads (not to be confused with the multipart/ top-level media type).

There is no standard way to resume an upload to a server after it has been interrupted. Implementations commonly utilize a POST request to allocate space on the server, then issue several more requests to write the data onto that space. The implementation will typically provide a way of reading the status of the upload, including: parts uploaded, amount remaining, errors, and result document.

Option: PATCH with a segmented upload media type

A PATCH request is capable of creating a new resource; combined with a media type that describes the specific byte ranges to be written to, a client would be capable of creating a new document split across several PATCH requests. See draft-wright-http-partial-upload.

Option: POST with 201 Accepted response

The client can send a POST request indicating a resource was created that may be used to send uploaded data. The 201 Accepted body will contain instructions on how to upload the remaining data. Once the data is completely uploaded, the asynchronous operation may resolve itself (the same way other asynchronous operations complete, if there are any).

Option: Expect header with Range header

The Range header is not defined for use in requests, because if the server did not understand the header, it would ignore it, overwriting the entire file with the partial contents; which is probably not what the client wants in any circumstances.

In a hypothetical extension of HTTP, a client could use the Expect header header to indicate it is using the Range header in a non-compatible manner. Servers would stop the request if they don't understand the Expect or Range header in a request. For example:

PUT /document.txt HTTP/1.1 Expect: Range Range: bytes 0-99/100

Option: URI query parameter

A subset of the URI template option, where a server exposes a URI parameter that selects a specific range of the document. For example, you could use PUT http://example.com/IMG2000.jpg?range=0-999 to write to only the first 1000 bytes of the document. Servers typically ignore unknown URI query parameters, so clients must have some way of knowing the server will apply the range.

This is a good solution for coupled APIs, but is difficult to build into Web browsers because there is no standardized mechanism to discover this capability.

URI Template

One way a server may advertise the format for the URI query parameter, and support for partial uploads, is with a URI Template.