Storage

S3 Uploads

Learn how to upload files to Supabase Storage using S3.

You can use the S3 protocol to upload files to Supabase Storage. To get started with S3, see the S3 setup guide.

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.

Use PutObject to upload smaller files, where retrying the entire upload won't be an issue. The maximum file size on paid plans is 50 GB.

For example, using JavaScript and the aws-sdk client:


_14
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
_14
_14
const s3Client = new S3Client({...})
_14
_14
const file = fs.createReadStream('path/to/file')
_14
_14
const uploadCommand = new PutObjectCommand({
_14
Bucket: 'bucket-name',
_14
Key: 'path/to/file',
_14
Body: file,
_14
ContentType: 'image/jpeg',
_14
})
_14
_14
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 for server-side uploads, when you want to maximize upload speed at the cost of resumability. The maximum file size on paid plans is 50 GB.

Upload a file in parts

Use the Upload class from an S3 client to upload a file in parts. For example, using JavaScript:


_15
import { S3Client } from '@aws-sdk/client-s3'
_15
import { Upload } from '@aws-sdk/lib-storage'
_15
_15
const s3Client = new S3Client({...})
_15
_15
const file = fs.createReadStream('path/to/very-large-file')
_15
_15
const upload = new Upload(s3Client, {
_15
Bucket: 'bucket-name',
_15
Key: 'path/to/file',
_15
ContentType: 'image/jpeg',
_15
Body: file,
_15
})
_15
_15
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 action.