mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 02:45:07 +03:00
* feat: allow 500 GB uploads * upsell * docs + pricing page * Update StorageSettings.tsx * Small alignment fix --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
72 lines
2.4 KiB
Plaintext
72 lines
2.4 KiB
Plaintext
---
|
|
id: 's3-uploads'
|
|
title: 'S3 Uploads'
|
|
description: 'Learn how to upload files to Supabase Storage using S3.'
|
|
subtitle: 'Learn how to upload files to Supabase Storage using S3.'
|
|
sidebar_label: 'Uploads'
|
|
---
|
|
|
|
You can use the S3 protocol to upload files to Supabase Storage. To get started with S3, see the [S3 setup guide](/docs/guides/storage/s3/authentication).
|
|
|
|
The S3 protocol supports file upload using:
|
|
|
|
- A single request
|
|
- Multiple requests via Multipart Upload
|
|
|
|
## Single request uploads
|
|
|
|
The `PutObject` action uploads the file in a single request. This matches the behavior of the Supabase SDK [Standard Upload](/docs/guides/storage/uploads/standard-uploads).
|
|
|
|
Use `PutObject` to upload smaller files, where retrying the entire upload won't be an issue. The maximum file size on paid plans is 500 GB.
|
|
|
|
For example, using JavaScript and the `aws-sdk` client:
|
|
|
|
```javascript
|
|
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
|
|
|
|
const s3Client = new S3Client({...})
|
|
|
|
const file = fs.createReadStream('path/to/file')
|
|
|
|
const uploadCommand = new PutObjectCommand({
|
|
Bucket: 'bucket-name',
|
|
Key: 'path/to/file',
|
|
Body: file,
|
|
ContentType: 'image/jpeg',
|
|
})
|
|
|
|
await s3Client.send(uploadCommand)
|
|
```
|
|
|
|
## Multipart uploads
|
|
|
|
Multipart Uploads split the file into smaller parts and upload them in parallel, maximizing the upload speed on a fast network. When uploading large files, this allows you to retry the upload of individual parts in case of network issues.
|
|
|
|
This method is preferable over [Resumable Upload](/docs/guides/storage/uploads/resumable-uploads) for server-side uploads, when you want to maximize upload speed at the cost of resumability. The maximum file size on paid plans is 500 GB.
|
|
|
|
### Upload a file in parts
|
|
|
|
Use the `Upload` class from an S3 client to upload a file in parts. For example, using JavaScript:
|
|
|
|
```javascript
|
|
import { S3Client } from '@aws-sdk/client-s3'
|
|
import { Upload } from '@aws-sdk/lib-storage'
|
|
|
|
const s3Client = new S3Client({...})
|
|
|
|
const file = fs.createReadStream('path/to/very-large-file')
|
|
|
|
const upload = new Upload(s3Client, {
|
|
Bucket: 'bucket-name',
|
|
Key: 'path/to/file',
|
|
ContentType: 'image/jpeg',
|
|
Body: file,
|
|
})
|
|
|
|
await uploader.done()
|
|
```
|
|
|
|
### Aborting multipart uploads
|
|
|
|
All multipart uploads are automatically aborted after 24 hours. To abort a multipart upload before that, you can use the [`AbortMultipartUpload`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html) action.
|