Storage File Retrieval Failed: "upstream image response failed for ..."
I've encountered some issue in my application, can anyone point me where I made a mistake in my code 🙏 :
I'm getting an error in this part of the code:
ERROR MESSAGE in the console log:
"""
upstream image response failed for https://upbeat-bandicoot-306.convex.cloud/api/storage/kg20zj0s2sczynrjpwqn04gbfx6msmjk 400
"""
ERROR MESSAGE when I click the link in the console log:
"""
{"code":"InvalidStoragePath","message":"Invalid storage path: "kg20zj0s2sczynrjpwqn04gbfx6msmjk" is not a valid UUID string."}
"""
though when I go to Convex Dashboard then inside the File Storage, Im getting the same UUID.
17 Replies
Here's my {next.config.mjs} file if this would help:
How do you generate the url to fetch the image? You should typically do that via ‘storage.get_getUrl’ from a function. https://docs.convex.dev/file-storage/serve-files
Serving Files | Convex Developer Hub
Files stored in Convex can be served to your users by generating a URL pointing
You can’t generate the url with ‘{convex.url/storage_id}’. It is not a valid way to generate it so we not longer allow it.
Thank you for pointing that out! @presley 🙏 That's very helpful, I know where I made a mistake now
@presley I'm still trying to debug it but I couldn't find a way how to fix the issue.
I have the generateUploadUrl mutation inside the
files.ts
Then I call useMutation
inside the onSubmit function form:
However, when I try to console.log the storageId
after extracting it to result.json(). Here's what I got:
"""
https://upbeat-bandicoot-306.convex.cloud/api/storage/upload?token=01d47ec10321efe60bf03b09b33128c5282e763b8b68fbdf5adffd511ec66a4a1f1abb8cf41bdb6aa1172caa78b04f28e053b960b63909722415d30629f475daf9e2509f9ceae8
"""
I'm not sure if that's how it supposed to look like, because when I try to check what the url supposed to look like when I went to the Convex Dashboard
-> File Storage
and I click download one of the files here's what the url supposed to look like:
"""
https://upbeat-bandicoot-306.convex.cloud/api/storage/2c561673-e026-4309-a82d-56d4360a1bd4
"""
but what I'm getting is the id of the image
"""
https://upbeat-bandicoot-306.convex.cloud/api/storage/kg208he07axmxws4rben4qbrzx6mrrbm
"""Have you tried running it? The upload and download urls aren't going to be the same thing.
Oh I see, you did run it and got the console log you mentioned
What you're getting back is correct, you'll want to write that storage id to your database.
Uploading and Storing Files | Convex Developer Hub
Files can be uploaded by your users and stored in Convex.
When you want to show the image somewhere, you'll generate a url via
ctx.storage.getUrl(storageId)
Serving Files | Convex Developer Hub
Files stored in Convex can be served to your users by generating a URL pointing
Okay, let me just try that @erquhart . I think that should work by now 🤞
@erquhart and @presley Thanks to the two of you! 🙏 I was able to fixed the issue!
Great to hear!
Can you help me with the same ?
@7uckingMad? what do u need help with?
im getting the same error :upstream image response failed
@7uckingMad? can you show me the code where you’re getting the error?
sure, I have send you the code on private
Aight, let’s talk there