Skip to content

fix(storage): pass metadata in uploadToSignedUrl#2129

Closed
viveknathani wants to merge 1 commit intosupabase:masterfrom
viveknathani:vivek/hack
Closed

fix(storage): pass metadata in uploadToSignedUrl#2129
viveknathani wants to merge 1 commit intosupabase:masterfrom
viveknathani:vivek/hack

Conversation

@viveknathani
Copy link
Copy Markdown

🔍 Description

uploadToSignedUrl silently ignored the metadata property in fileOptions, so custom user metadata was never persisted when uploading via signed URLs.

What changed?

The fix adds metadata handling to all three body type paths in uploadToSignedUrl, matching the behavior of uploadOrUpdate and also forwards fileOptions.headers to the request, consistent with upload(). Tests have been added too.

Why was this change needed?

This was inconsistent with the standard .upload() method, which correctly processes and attaches metadata to the request body/headers.

Originally raised here: supabase/storage#823

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run npx nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

@viveknathani viveknathani requested review from a team as code owners February 22, 2026 10:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Enhanced upload functionality with support for custom per-call headers and improved metadata handling across different upload types.
  • Tests

    • Added comprehensive test coverage for metadata handling in signed URL upload scenarios.

Walkthrough

The pull request modifies the StorageFileApi to enhance header and metadata handling across upload flows. Headers are now declared as mutable to enable dynamic merging of per-call headers. Metadata handling is introduced conditionally based on the request body type: for Blob and FormData uploads, metadata is appended to the request body as a JSON field; for raw body uploads, metadata is sent as a base64-encoded JSON string via the x-metadata header. The same adjustments are applied to both unsigned and signed URL upload flows to ensure consistent treatment. No public method signatures are altered. The changes are accompanied by new test cases that verify metadata handling across different upload scenarios.

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@viveknathani
Copy link
Copy Markdown
Author

hi @mandarini - just bumping this since it's been a couple of weeks. github already requested review from the codeowners but i haven’t heard back yet. would appreciate it if you could take a look when you get a chance, thanks!

@mandarini
Copy link
Copy Markdown
Contributor

Hi @viveknathani, thanks for taking the time to put this together, the fix is correct and the approach is exactly right. I do apologize for taking so long to review, there were some other priorities to look at, and this fell behind a bit. Thank you for your patience and understanding.
I'm going to close this in favor of #2155 which tackles the same issue but also covers two additional cases: stream bodies on Node 20+ (which require duplex: 'half' on the fetch call, same as uploadOrUpdate), and a pre-existing bug where missing cacheControl/contentType in fileOptions would send "undefined" strings to the server. Do not be discouraged, and I do really appreciate the contribution. Feel free to keep an eye out for other issues to tackle! Thank you for contributing to Supabase! 💚

@mandarini mandarini closed this Mar 9, 2026
@viveknathani
Copy link
Copy Markdown
Author

makes sense, thanks for the review!

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.

2 participants