Back

Unable to access the images stored in bucket

  • 1
  • Web
  • Cloud
Don't Know
3 Oct, 2023, 14:56

I keep getting " 'url' is valid but upstream response is invalid" when I try to fetch the preview using storage.getFilePreview

I am passing all the parameters correctly and the access at bucket level is set to CREATE for All Users and at file/image level it's set to READ, UPDATE, DELETE for the user that uploaded the file.

Yet I keep getting this error with a 404 status code

TL;DR
The user is unable to access the images stored in a bucket. They are getting a 404 error when trying to fetch the image preview using storage.getFilePreview. They have checked the documentation and their code, and everything seems to be correct. They are passing all the parameters correctly and have set the appropriate access levels at the bucket and file/image level. They are using emailSession instead of JWT. It is suggested to check if the JWT is being passed correctly using setJWT. Private files cannot be accessed without a JWT.
safwan
3 Oct, 2023, 16:10

Can you share your code?

Ernest
3 Oct, 2023, 16:21

Are you passing in the jwt with setJWT('eyJJ9.eyJ...886c4'); ? Files that are not public (no guest) access can't be accessed without a jwt. Checkout this response by Steven https://discord.com/channels/564160730845151244/1157804153427460126/1158411341908934687

Link to Jwt docs: https://appwrite.io/docs/products/auth/jwt#proof-of-identity

Don't Know
3 Oct, 2023, 16:22

I am using emailSession not jwt

Don't Know
3 Oct, 2023, 16:23

Wait I'll just push the code to github and maybe that should provide more context

Ernest
3 Oct, 2023, 16:23

I think it doesn't matter you still need a jwt to access private files.

Ernest
3 Oct, 2023, 16:23

Ok

Don't Know
3 Oct, 2023, 16:32

The code in feat/authentication branch is the one were I am implementing the auth atm

Don't Know
3 Oct, 2023, 16:32

the call I make for getting file preview is in

Don't Know
3 Oct, 2023, 16:33

lib > getUrl

Don't Know
3 Oct, 2023, 16:33

this Url is used in components > TodoCard.tsx to display the image

Don't Know
3 Oct, 2023, 16:35

store > AuthStore contains the methods like signup, login, googleLogin etc

Don't Know
3 Oct, 2023, 16:49

it's weird, I do get the preview but I also get that 404

Ernest
3 Oct, 2023, 17:13

That's weird and I'm sorry I can't help. Just wait for a core team member or moderator to reply.

Don't Know
3 Oct, 2023, 17:14

That's okay thanks for your time

safwan
3 Oct, 2023, 17:46

Can you log the output of url?

safwan
3 Oct, 2023, 17:48

See what the output is, cuz I don't think it should have anything. According to the docs for getFilePreview, the response is just a 200 OK

Don't Know
4 Oct, 2023, 14:54

Returns this

Don't Know
4 Oct, 2023, 14:58

and using .toString on the url object returns the value of href as string

Don't Know
4 Oct, 2023, 15:56

turns out everything is fine on appwrite side..... it's Next 13 that's causing it with it's mostly amazing but at time annoying Image component

Don't Know
4 Oct, 2023, 16:25

I'll be deleting this branch so it will no longer be accessible anymore

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more