Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
Storing a Video blob in Firebase with custom Name attribute, returns Undefined

The problem is all my Collections Documents are referring to the same blob file because each upload replaces the existing Storage blob.

I think I need to assign a Name to the Blob to store a New Entry each time an upload happens.

Trying to assign Name with Math.random() however has not worked. Suggestions?

import { useParams, useHistory } from "react-router-dom";
const { productID } = useParams();

async function handleSubmitUpload() {
        if (recordedChunks.length) {
            const promises = [];
            const blob = new Blob(recordedChunks, {Name: Math.random()}, {type: "video/webm"});


            const reviewRef = await storage().ref(`prodReviews/${blob.Name}`)
            const uploadTask = await storage().ref(`prodReviews/${blob.Name}`).put(blob);
            await promises.push(uploadTask);
          
          
            const videoUrl = await reviewRef.getDownloadURL();
            const timestamp = new Date();

            await firestore
                .collection("products")
                .doc(productID)
                .collection("productReviewClips")
                .add({videoUrl, userID: auth.currentUser.uid, createdDate: timestamp }) 

               
                history.push(`/product/${productID}`);

                setRecordedChunks([]);
        }
    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The Blob() constructor seems to take only 2 parameters but you are passing 3. You can use either Firestore SDK or UUID to generate random IDs and use them as file names as shown below:

const blob = new Blob(recordedChunks, {type: "video/webm"});

// Get a random ID 
const randomId = firestore.collection("test").doc().id

// Upload to Firebase Storage
const reviewRef = await storage().ref(`prodReviews/${randomId}`)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda