Skip to content

fix: preserve charset in content-type for non-zero byte files#975

Open
SushanthMusham wants to merge 1 commit intosupabase:masterfrom
SushanthMusham:fix/charset-content-type
Open

fix: preserve charset in content-type for non-zero byte files#975
SushanthMusham wants to merge 1 commit intosupabase:masterfrom
SushanthMusham:fix/charset-content-type

Conversation

@SushanthMusham
Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When uploading a non-zero byte file with a Content-Type that includes a charset parameter (e.g. text/markdown; charset=UTF-8), the charset is silently dropped. This happens because bufferedMultipartUpload calls headObject after upload, and S3 normalizes the Content-Type by stripping the charset before returning it.
Fixes #816

What is the new behavior?

The original contentType parameter (which contains the full Content-Type including charset) is now used directly in the return value, instead of relying on the normalized response from S3's headObject. Falls back to metadata.mimetype if contentType is empty.

// Before
mimetype: metadata.mimetype

// After
mimetype: contentType || metadata.mimetype

Additional context

Zero-byte files were already handled correctly because they bypass headObject entirely. This fix brings non-zero byte files in line with the same behaviour.

@SushanthMusham SushanthMusham requested a review from a team as a code owner April 6, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload file content type charset is dropped

1 participant