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

A bucket named "public" will fail download of files with 404. #119

Closed
GaryAustin1 opened this issue Mar 6, 2022 · 2 comments
Closed

A bucket named "public" will fail download of files with 404. #119

GaryAustin1 opened this issue Mar 6, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@GaryAustin1
Copy link

GaryAustin1 commented Mar 6, 2022

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:
#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:

shot

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.

@GaryAustin1 GaryAustin1 added the bug Something isn't working label Mar 6, 2022
@GaryAustin1 GaryAustin1 changed the title A public bucket named "public" will fail download of files with 404. A bucket named "public" will fail download of files with 404. Mar 6, 2022
@thebengeu
Copy link
Member

thebengeu commented Mar 9, 2022

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?

@fenos
Copy link
Contributor

fenos commented Sep 26, 2022

From my tests this seems to be fixed, closing

@fenos fenos closed this as completed Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants