Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

85
Vistas
Firebase file upload crashes React Native app using Expo

I'm trying to upload a video file to Firebase but app crashes without any logs. There are no logs, the app just crashes.

const id = uuid.v4();
const path = `videos/${user.uid}/${id}`;

try {
  const fileRef = ref(storage, path);
  const blob = await new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest();
    xhr.onload = function() {
      resolve(xhr.response);
    };
    xhr.onerror = function(e) {
      console.log(e);
      reject(new TypeError('Network request failed'));
    };
    xhr.responseType = 'blob';
    xhr.open('GET', uri, true);
    xhr.send(null);
  });

  const uploadTask = uploadBytesResumable(fileRef, blob);
  uploadTask.on(
      'state_changed',
      (snapshot) => {
        const prog = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
        callback(prog);
      },
      (error) => {
        errorCallback(error);
      },
      () => {
        getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
          console.warn('Complete', downloadURL);
        });
      },
  );
} catch (error) {
  console.log(error);
}

The same code works fine on Android phones but crashes on iOS.

7 months ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos