Get url after file upload #1336
Replies: 3 comments 1 reply
-
I'm having the same problem. Did you figure it out? It's strange because if I So the url value does exist but |
Beta Was this translation helpful? Give feedback.
-
im having the same issues. did either of you find a solution? UPDATE: so i got it working, but in an extremely convoluted way that im not even sure is the right way to do it, but it technically works. basically it takes a bit for the url.value to update from null to the actual url, so i used an onUpdated() function to check when the url.value changes. and once its changed, then fire off the function that sends the url data to firestore in my use case. again, this works, but it doesnt feel right lol. id prefer a real solution, but for the time being this technically is working for me. all im doing is making an backend page to load data into a firestore database, so only i will be using it so this solution may not be appropriate for every situation. but maybe it'll help others get something working. these are the functions.
|
Beta Was this translation helpful? Give feedback.
-
The URL updates after the upload but is not awaited as it's not always required and would be wasteful in slow networks (See vanilla example https://firebase.google.com/docs/storage/web/upload-files). Instead, you need to await const { refresh, upload, url } = useStorageFile(...)
await upload()
await refresh()
// url is updated! |
Beta Was this translation helpful? Give feedback.
-
How do I get the URL after I upload a file?
const data = item.value?.file[0]
await upload(data)
if (uploadProgress.value==1) {
console.log(url.value)
})
The upload works fine, but I get
undefined
in my logs. Am I doing something wrong?Beta Was this translation helpful? Give feedback.
All reactions