Firebase 存储子引用 getDownloadURL 返回 "childPath.split is not a function"

Firebase Storage child ref getDownloadURL returning "childPath.split is not a function"

错误是 .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([]);
                    })

                }
}

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 reviewRef.getDownloadURL();

// Add Firestore document
await firestore.doc(`products/${productID}`).set({videoUrl}, { merge: true });