Storage

Creating Buckets

You can create a bucket using the Supabase Dashboard. Since storage is interoperable with your Postgres database, you can also use SQL or our client libraries. Here we create a bucket called "avatars":

Restricting uploads

When creating a bucket you can add additional configurations to restrict the type or size of files you want this bucket to contain. For example, imagine you want to allow your users to upload only images to the avatars bucket and the size must not be greater than 1MB.

You can achieve the following by providing: allowedMimeTypes and maxFileSize


_10
// Use the JS library to create a bucket.
_10
_10
const { data, error } = await supabase.storage.createBucket('avatars', {
_10
public: true,
_10
allowedMimeTypes: ['image/*'],
_10
fileSizeLimit: '1MB',
_10
})

If an upload request doesn't meet the above restrictions it will be rejected.

For more information check File Limits Section.