Fix failing file upload to Supabase #22293
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scope
Some investigation shows that the
Content-Length
header we are relying on to identify the file size in the Supabase storage driver is not being sent in the cloud offering of Supabase. This seems to be caused by some Cloudflare configuration related to theHEAD
request method1 which Supabase uses in front of their hosted offering.If this header is missing we are trying to insert
NaN
as filesize into the DB, causing the error.In order to avoid further problems by relying on the headers of the
HEAD
method I switched to querying the/list
endpoint of the bucket with the filename assearch
parameter, effectively returning the one file that matches.With this approach we would need to be concerned about the user storing other files in the bucket that happen to start with the full filename (uuid + extension) like the file we are interested. But even in that case they are sorted by the filename by default, always returning the shorter name first, which is the one we are looking at.
Potential Risks / Drawbacks
?
Review Notes / Questions
Fixes #22168
Footnotes
https://community.cloudflare.com/t/content-length-is-removed-on-response-of-head-method/628350/26 ↩