TUS - Open Protocol for Resumable File Uploads
Tus is a new open protocol for resumable uploads built on HTTP. It supports any language, any platform and any network.
Introduction
Tus is a new open protocol for resumable uploads built on HTTP. It offers simple, cheap and reusable stacks for clients and servers. It supports any language, any platform and any network.
There are many freely available client and server implements. An demo is running at https://tus.io/demo.
Tus is a
low-levelbuilding block, there's no one right way to do deploy resumable file uploads with it.
When should use tus?
- app running on partly unreliable networks.
- handle large files, avoid reupload.
- want to provide your users with the ability to pause & resume.
- click for more detail
How to get started
You'll need:
server implementation(like:tusd).client implementation(like:tus-js-clientfor browsers and Node.js, orUppy).
Protocol
A tus upload composed of different HTTP requests, each one has it's own purpose:
POSTFirst, client sends a
POSTrequest to the server to initiate the upload.
This request tells the server basic information such as size or additional metadata.
If the server accepts, will return a successful response with theLocationheader set to the upload URL.
This upload URL is used to uniquely identify and reference the newly-created upload resource.
For example:
PATCHOne the upload has been created, the client can start to transmit the actual upload content by send a
PATCHrequest to the upload URL (returned in the previousPOSTrequest).
ThePATCHrequest sholud contain as much upload content as possible to minimize the upload duration. Also must contain theUpload-Offsetheader (tells the server at which byte offset the server should write the uploaded data).
Your upload will be done whenPATCHrequest successfully transfers the entirety of the upload contnet.HEADIf
PATCHinterrupted or failed, if the client attempt to resume, the client must know how much data the server has received.
Therefore,HEADrquest sent to the upload URL, client inspecting the returnedUpload-Offsetheader. The client will send anotherPATCHrequest until the upload is completely done.
DELETEA
DELETErequest can be sent to the upload URL to delete an upload. Ater this, the upload can be cleaned up by the server, resuming the upload is not possible anymore.
Concepts
Upload-Offset: indicates a byte offset whitin a resource. (The simple way is to consider as a completely uploaded byte length, identifies the starting position of the data that has been received by the server.)Upload-Length: indicates the size of the entire upload in bytes.- click for more detail
Leave a comment?

