Files Uploads
Uploads
tip: drop a whole folder on the drive
On this page
In parts, to the bucket
A file larger than 8 MiB goes in parts, each to an address signed for its exact length, a few at once.
POST /uploadssays where to send each part; the parts go to the bucket;POST /uploads/finishputs them together, and the server checks the size that arrived before the file is listed.- A part that fails is tried again, five times with a longer wait each, from what arrived. Files of up to 5 GiB unless
maxSizesays otherwise. - The bucket must expose ETag in its rule of origins: the page reads it from each part, and the server needs it to put them together.
The panel of uploads
Three files at once; each says how much has gone, how fast and how long it has left, and so does all of it together.
One is stopped, and what of it arrived taken away; one that failed is tried again from what arrived. The speed is that of the last few seconds, so a time left follows a change without jumping at every jolt.
const { uploads, summary } = useUploads({ check: true });
// summary.remaining: seconds until all are up, at the speed all go at together
// uploads[i].remaining: the same, of oneResumed after a cut
An upload cut, or left when the page closed, goes on from where it was when the same file is uploaded again to the same place.
// A file cut halfway, or left when the page closed, is uploaded again:
await client.upload(file, { parent }); // asks the server what arrived, sends the restThe page remembers it in localStorage for a day, as long as the server keeps the parts. One never gone on with waits in the bucket for a lifecycle rule (“abort incomplete multipart uploads after 1 day”).
Whole folders
Dropped on the drive, or chosen with “Upload a folder”, a folder goes up with all that is in it: its folders made top down, the empty ones too, “(2)” for a name taken there.
The same file, asked about
Before each file goes, it is looked for in the drive.
| Found | Asked |
|---|---|
| The same bytes, anywhere one may read | Upload anyway, or skip. |
| A file of its name where it goes | Replace it (a new version of it), keep both (“(2)”), or skip. |
The bytes are told by a SHA-256 made in the page, for files of up to 64 MiB, kept with the version (POST /duplicates finds it). “Do the same for all the others” answers every one of a kind at once. checkUploads={false} uploads without asking.
What goes with it
Made in the page and sent after the file, which is up whether or not they are.