該錯誤是由 .child(blob) 引起的,我嘗試過:
.child()
.child({blob})
.child(blob.name)
“blob”是在代碼的前面部分定義的,它應該仍然可以在存盤中參考它。
async function handleSubmitUpload() {
if (recordedChunks.length) {
const blob = new Blob(recordedChunks, {
type: "video/webm",
});
await storage().ref(`prodReviews/${blob}`).put(blob);
console.log( "success storing" (blob));
await storage()
.ref('prodReviews')
.child(blob)
.getDownloadURL()
.then((videoUrl) => {
firestore.doc(`products/${productID}`)
.set({videoUrl}, { merge: true });
console.log("Review for item uploaded successfully")
setRecordedChunks([]);
})
}
}
uj5u.com熱心網友回復:
該child()方法將物件的路徑作為引數而不是 blob。嘗試重構代碼,如下所示:
// Create a storage reference
const reviewRef = storage().ref(`prodReviews/${blob}`);
// Upload the object to that ref
await reviewRef.put(blob);
// Get download URL
const videoUrl = await videoRef.getDownloadURL();
// Add Firestore document
await firestore.doc(`products/${productID}`).set({videoUrl}, { merge: true });
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/346684.html
標籤:javascript 火力基地 火力存储
