storage
storage copied to clipboard
A bucket named "public" will fail download of files with 404.
Bug report
If you create a bucket called "public", using the download command in the UI and doing a storage.from.download from the API will return 404 for any files. Public URL works as expected if a public bucket.
Probably related: https://github.com/supabase/storage-api/issues/22
Describe the bug
using
supabase
.storage
.from('public')
.download('shot.jpg')
GET https://instanceid.supabase.co/storage/v1/object/public/shot.jpg
404
Using UI download from menu:
NOTE adding public/ to the path in .download does work if bucket is public.....
GET https://instanceid.supabase.co/storage/v1/object/public/public/shot.jpg
Works (if bucket public)
Edit: Issue seems to be this code:
https://github.com/supabase/storage-api/blob/1e55aa38e8572dfb399527e033edfa8e86f86a01/src/routes/object/getPublicObject.ts#L38
fastify.get<getObjectRequestInterface>(
'/public/:bucketName/*',
{
If I read that correctly, a url route with public in it automatically gets treated as a request for a different interface than any other name. So a bucket named "public" can not work. This seems hard to fix without major change to the storage protocol. Probably easier to not allow buckets to be named public in the bucket creation process and deal with existing buckets on a case by case basis (but is difficult as buckets cannot be renamed at least for the api I don't believe).
To Reproduce
Create a public bucket named public. Upload a file. Click download from UI. Get 404 error. Create a public bucket named test. Upload same file. Click on download from UI it works. EDIT: creating a private bucket named "public" also fails.
Expected behavior
A public bucket named "public" should work, or error on creation, or at least be documented not to work.
System information
Current supabase.js and Supabase instance.
Additional context
Add any other context about the problem here.
Thanks @GaryAustin1 for your detailed bug report!
@inian #24 was intended to fix this, seems like https://github.com/supabase/storage-api/blob/1e55aa38e8572dfb399527e033edfa8e86f86a01/src/routes/object/getObject.ts#L103 was added but from.download()
wasn't updated, so using that new route should fix this issue?
From my tests this seems to be fixed, closing