storage icon indicating copy to clipboard operation
storage copied to clipboard

storage update results in "The resource was not found"

Open eric-naguras opened this issue 3 years ago • 1 comments

Bug report

Describe the bug

When I try to update a file, basically replacing the content but keeping the same file name, I get an error "The resource was not found".

To Reproduce

  1. I get a file using a file input element.
  2. I assign a name to a name variable
  3. I upload the file to storage with:
await supabase.storage.from('bucketName').upload(fileName, files[0]) (no error, file is stored)
  1. I get another file with a file input element
  2. While using the same file name, I update the file with:
await supabase.storage.from('bucketName').update(fileName, files[0]) (errors with The resource was not found)

If I try to upload a different file with the same name, I do get an (expected) error "duplicate key value violates unique constraint "bucketid_objname""

Expected behavior

I expect the file in the bucket to be updated, different content with same file name.

System information

  • OS: Ubuntu 22.04
  • Browser chrome
  • Version of supabase-js: 1.35.3
  • Version of svelte-kit: 1.0.0-next.354

eric-naguras avatar Jul 05 '22 13:07 eric-naguras

Hi @eric-naguras! Do you have any RLS policies added for storage objects? The "The resource was not found" message when performing the update of an existing object seems to indicate that you've added policies to permit INSERT of new objects, but not UPDATE of existing objects.

bnjmnt4n avatar Aug 01 '22 05:08 bnjmnt4n

Closing for inactivity, feel free to reach out if needed further assistance

fenos avatar Sep 26 '22 14:09 fenos

For anyone facing this issue despite having everything right in code, make sure you have the right RLS policies set and that all operations are allowed for such policy. Do that as you set the policy!

Hussseinkizz avatar Oct 28 '22 23:10 Hussseinkizz