Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom file size limit and mime types at bucket level #151

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

fenos
Copy link
Contributor

@fenos fenos commented Mar 6, 2023

What kind of change does this PR introduce?

Feature

What is the new behavior?

It is now possible to specify, file_size_limit and allowed_mime_types when creating a bucket.
These limits will be imposed during the upload of an asset, allowing you to validate server side the values

Example:

// Create Bucket with file size limit 20mb
await storage.createBucket('bucket-name', {
      public: true,
      fileSizeLimit: '20mb',
      allowedMimeTypes: ['image/jpeg'],
})

// load the file
const bigFile = ... // 1GB

// Upload
const res = await storage.from('bucket-name').upload(bigFile, {
   contentType: 'image/jpeg',
})

// Response
expect(res.error).toEqual({
   error: 'Payload too large',
   message: 'The object exceeded the maximum allowed size',
   statusCode: '413',
})

@fenos fenos force-pushed the feat/bucket-size-limit-and-mime-types branch from 47b3b4c to f1a502c Compare March 6, 2023 10:36
@fenos fenos merged commit e40c1be into main Apr 6, 2023
@fenos fenos deleted the feat/bucket-size-limit-and-mime-types branch April 6, 2023 08:00
@kiwicopple
Copy link
Member

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants