I currently building a web application (build with react, nodejs & firebase) where I have a form where users can upload an image and fill in other information.
When the user submits the form:
- other information will be stored directly in the firebase firestore.
- The image will be uploaded to firebase storage. Only after that, my cloud function will listen to that event and update the collection accordingly with the image URL.
Below is roughly the code. No issue with this.
exports.onFileUploaded = functions.storage.object().onFinalize(async obj => { // embed new file url return firestore .collection("user") .doc(docId) .update({ image: fileURL }) .catch(e => console.error(e)) }) The problem is, for some occasions, I found out the document on storage is updated with the image URL, but the object is not found on the storage. Technically it won't be possible because the only way a document got an image URL is after the cloud function listens to an event that a file is uploaded to storage.
Do you guys have any clue what should I do to fix this? Or do you guys have any idea how should I handle this better?
Any idea would be greatly appreciated.
https://stackoverflow.com/questions/67223049/missing-image-uploaded-on-firebase-storage-using-cloud-function-to-update-fires April 23, 2021 at 10:05AM
没有评论:
发表评论