storage-js icon indicating copy to clipboard operation
storage-js copied to clipboard

feat: add private method to get expected content type

Open anonymousRecords opened this issue 1 year ago • 0 comments

What kind of change does this PR introduce?

Related to issue: https://github.com/supabase/supabase-js/issues/1248

This PR expands MIME type support in the _getExpectedContentType function and adds MIME type validation during upload.

What is the current behavior?

createSignedUploadUrl does not validate MIME types.

What is the new behavior?

  • Added more MIME types to the _getExpectedContentType function for broader file type support.
  • Implemented a check to compare the expected MIME type with the actual Content-Type during upload, throwing an error if they don't match.

Additional context

  • The selection of additional MIME types was done arbitrarily. If support for more file types is needed, I'm open to suggestions and can expand the list accordingly.
  • Currently, the function throws a StorageError when the content type doesn't match. I'm seeking feedback on whether using console.warn for a warning instead would be more appropriate.

anonymousRecords avatar Sep 29 '24 06:09 anonymousRecords