storage-js
storage-js copied to clipboard
feat: add private method to get expected content type
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
_getExpectedContentTypefunction 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.