Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing file upload to Supabase #22293

Merged
merged 8 commits into from Apr 28, 2024
Merged

Fix failing file upload to Supabase #22293

merged 8 commits into from Apr 28, 2024

Conversation

hanneskuettner
Copy link
Contributor

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 the HEAD 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 as search 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

  1. https://community.cloudflare.com/t/content-length-is-removed-on-response-of-head-method/628350/26

Copy link

changeset-bot bot commented Apr 23, 2024

🦋 Changeset detected

Latest commit: 7401235

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@directus/storage-driver-supabase Patch
@directus/api Patch
directus Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@prodkt
Copy link

prodkt commented Apr 25, 2024

This also is impacting us. Supabase as the db service, SVG's being the culprit. The original ticket I arrived from was exact outcome thats returning for us on this end.

@paescuj paescuj self-assigned this Apr 28, 2024
Copy link
Member

@paescuj paescuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

@paescuj paescuj merged commit 0d7441e into main Apr 28, 2024
4 checks passed
@paescuj paescuj deleted the fix-22168-supabase-storage branch April 28, 2024 23:45
@github-actions github-actions bot added this to the Next Release milestone Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

INTERNAL_SERVER_ERROR importing SVGs from a url or localhost with Supabase
3 participants