Calonz
Calonz10mo ago

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.
No description
No description
No description
17 Replies
Calonz
CalonzOP10mo ago
Here's my {next.config.mjs} file if this would help:
No description
presley
presley10mo ago
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
presley
presley10mo ago
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.
Calonz
CalonzOP10mo ago
Thank you for pointing that out! @presley 🙏 That's very helpful, I know where I made a mistake now
Calonz
CalonzOP10mo ago
@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 """
No description
No description
erquhart
erquhart10mo ago
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.
erquhart
erquhart10mo ago
When you want to show the image somewhere, you'll generate a url via ctx.storage.getUrl(storageId)
erquhart
erquhart10mo ago
Serving Files | Convex Developer Hub
Files stored in Convex can be served to your users by generating a URL pointing
Calonz
CalonzOP10mo ago
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!
erquhart
erquhart10mo ago
Great to hear!
7uckingMad?
7uckingMad?10mo ago
Can you help me with the same ?
Calonz
CalonzOP10mo ago
@7uckingMad? what do u need help with?
7uckingMad?
7uckingMad?10mo ago
im getting the same error :upstream image response failed
Calonz
CalonzOP10mo ago
@7uckingMad? can you show me the code where you’re getting the error?
7uckingMad?
7uckingMad?10mo ago
sure, I have send you the code on private
Calonz
CalonzOP10mo ago
Aight, let’s talk there

Did you find this page helpful?