Can't interact with files in storage (StorageApiError: Object not found)
When I try to download files manually uploaded to storage buckets in sveltekit I get the error
StorageApiError: Object not found
. I already tripple-checked every spelling of bucket name and filepath and it is all correct.
I know that supabase is responding because I have another page that gets text from a table and it does that no problem.
The storage bucket has no policies because I want it to be accessible by everyone since my app doesn't require an account.
Technical information:
npm: '10.2.4' node: '21.5.0' supabase: '1.131.3' svelte-kit: '1.2.0'Full error message P.S: If it wasnt clear already I'm using SvelteKit
7 Replies
You have to have some sort of policy to work.
No policy means no access.
So you can just have the bucket_id = 'name' for all the policies.
Also if you allow everyone to access your storage (or database) and ever release your anon key and url (like for browser client) then someone could use up all your storage or database. Normally you want to limit what anon users can do.
If this is a public bucket then you can have a URL to access the file directly with getPublicUrl(). But all other operations still require policies.
so I just need to add the
bucket_id = 'name'
to this area?
also, can you give me any recomendations on what policies to write in order to keep the database safe but still allow anon users to upload images and see them?
I don't know of way to allow anon uploads and have it be safe. How will you stop someone for uploading files if you don't know who they are?
thats a good point, I will attempt to add account functionality later. When I do, what policies should I add?
You at a minimum have ability to say only users who have joined your site can upload and so can stop them if they do bad things. This is all based on Supabase Auth roles and user ids.
Alright, thanks!