Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: add more information on the upload guide

fenosd032a571f3c1
diff --git a/apps/docs/pages/guides/storage/uploads.mdx b/apps/docs/pages/guides/storage/uploads.mdx
index 47deaa6267e..552ff7f603d 100644
--- a/apps/docs/pages/guides/storage/uploads.mdx
+++ b/apps/docs/pages/guides/storage/uploads.mdx
@@ -51,7 +51,7 @@ We are rolling this feature gradually, please contact us if you want to be prior
</Admonition>
-The Resumable upload method is recommended for uploading large files that may exceed 6MB in size or for scenarios where network stability is a concern.
+The Resumable upload method is recommended for uploading large files that may exceed 6MB in size or for scenarios where network stability is a concern or if you simply want to have a progress bar for your uploads.
Supabase Storage implements the [TUS protocol](https://tus.io/) to enable resumable uploads. TUS stands for The Upload Server and is an open protocol for supporting resumable uploads. The protocol allows the upload process to be resumed from where it left off in case of interruptions.
This method can be implemented using the tus-js-client library, or other client-side libraries like [Uppy-js](https://uppy.io/docs/tus/) that support the TUS protocol.
@@ -110,6 +110,31 @@ function uploadFile(bucketName, fileName, file) {
}
```
+### Upload URL
+
+When uploading using the resumable upload endpoint, the TUS client creates a unique URL for each upload, even for uploads to the same path.
+All the chunks will be uploaded to this URL using the `PATCH` method.
+
+This URL will be valid for **up to 24 hours**. If the upload is not completed within 24 hours, the URL will expire and you'll need to start the upload again.
+The tus client library will automatically create a new URL if the previous one expires.
+
+
+### Concurrency
+
+When two or more clients tries to upload to the same Upload URL only one of them will succeed. The other clients will receive a `409 Conflict` error.
+Only 1 client can upload to the same Upload URL at a time, this is to prevent data corruption.
+
+<Admonition type="note">
+We do not yet support checksum validation for the uploaded chunks.
+This means that if the client uploads a valid chunk that respect the current offset from a different file, the upload will still succeed.
+
+
+This has to be done intentionally by the client, it's unlikely to happen in normal circumstances.
+</Admonition>
+
+When two or more clients upload a file to the same path using different upload URLs, the first client to complete the upload will succeed and the other clients will receive a `409 Conflict` error.
+If you provide the `x-upsert` header the last client to complete the upload will succeed instead.
+
### UppyJS Example
You can check a full example using UppyJS [Here](https://github.com/supabase/supabase/tree/master/examples/storage/resumable-upload-uppy)
@@ -121,6 +146,17 @@ Framework integration for UppyJS:
- [Vue](https://uppy.io/docs/vue/)
- [Angular](https://uppy.io/docs/angular/)
+
+## Overwriting Files
+
+When uploading a file to a path that already exists, the default behavior is to return a `409 Conflict` error.
+If you want to overwrite a file on a specific path you can set the `x-upsert` header to `true`.
+
+We do advise against overwriting files when possible, as the CDN will take sometime to propagate the changes to all the edge nodes leading to stale content.
+Uploading a file to a new path is the recommended way to avoid propagation delays and stale content.
+
+If you want to know more about our CDN, check the [CDN](/docs/guides/storage/cdn) guide.
+
## Access Control with RLS Policies
Both the standard file upload and TUS resumable file upload methods in Supabase Storage support Row-Level Security (RLS) policies. RLS allows you to define fine-grained access control rules to restrict access to files based on user roles, permissions, or other criteria. This ensures that your files are secure and accessible only to authorized users.