I'm stuck trying to upload a picture I took with expo camera into firebase storage

57 views Asked by At

could you please help me uploading the pictures I take using expo camera, below the code I'm using right now, I see the image in firebase storage with more that 5mb of size but it's unreadable, below the code I'm using :

  const takePic = async () => {
    let options = {
      quality: 1,
      exif: false,
      base64: true,
    };
    let newPhoto = await cameraRef.current.takePictureAsync(options);
    uploadToFirebase("data:image/jpg;base64," + newPhoto.base64);
    setPhoto(newPhoto);
  };

  const uploadToFirebase = async (uri) => {
    const file = new Blob([uri], { type: "image/jpg" });

    const storageRef = ref(storage, "reportEvent/image4");

    uploadBytes(storageRef, file).then((snapshot) => {
      console.log("Uploaded a blob or file!");
    });
  };

I expect previewing the picture in the firebase storage dashboard

0

There are 0 answers