0

I tried to do it like how they do it in this post's answer how to check if file exists in Firebase Storage?

But I keep getting a error when I try to use that @google-cloud/storage package. Is there another way of checking if a file exists without catching and throwing an error?

This is how I'm currently uploading the file, which is an image, to my firebase

 firebase.storage().ref('users/'+user.uid + '/profile.jpg').put(file.target.files[0]).then( () => {
      console.log("Successfully uploaded image")
    }).catch(error => {
      console.log("Error uploading image: " + error);
    });

This is the line of code that causes it to break

const {Storage} = require('@google-cloud/storage');

And I get this error in the console. util.js:602 Uncaught TypeError: The "original" argument must be of type Function

Any ideas or tips?

cris
  • 265
  • 3
  • 11
  • What exactly goes wrong with the method described in the other answer? – Renaud Tarnec Mar 09 '21 at 20:03
  • It requires me to use the ```@google-cloud/storage``` package. And when I try to import it into my program, it causes it to break. I'll edit the post to add the line of code that causes the error – cris Mar 09 '21 at 20:14

0 Answers0