mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
24 lines
1.1 KiB
Markdown
24 lines
1.1 KiB
Markdown
## Resumable Uploads with Supabase Storage and Uppy
|
|
|
|
This example shows how to use signed urls from [Supabase Storage](https://supabase.com/docs/reference/javascript/storage) with [Uppy](https://uppy.io/) to upload files to Supabase Storage using the TUS protocol (signed resumable uploads).
|
|
|
|
This works by calling `createSignedUploadUrl()` to get a token for each file, and passing that token via the `x-signature` header when uploading the files
|
|
|
|
### Running the example
|
|
|
|
- Start local supabase project `supabase start`
|
|
- Open the index.html file and set `SUPABASE_PUBLISHABLE_KEY` to the value output when starting the supabase cli
|
|
- Serve the index.html file locally (e.g. with Python Simple HTTP Server or http-server npm package) and start uploading:
|
|
|
|
```bash
|
|
# python http server
|
|
python3 -m http.server
|
|
|
|
# npm http-server
|
|
npx http-server
|
|
```
|
|
|
|
### How it works
|
|
|
|
In index.html the `uppy.on('file-added')` hook calls the [create-upload-token](supabase/functions/create-upload-token/index.ts) function which creates a token for each added file and attaches it to that file's header config as `x-signature`.
|