Home > Mobile >  how to get data URL from upload bytes in firesbase?
how to get data URL from upload bytes in firesbase?

Time:03-01

How to get data URL from snapshot after uploading to storage in firebase, I cannot find the link in the snapshot, there must be another method to complete the action.

  if (input?.files![0]) {
        const storage = getStorage();
        const storageRef = ref(storage, `profiles/${_authContext.currentUser.uid}/${input?.files![0].name}`);
        // 'file' comes from the Blob or File API
        uploadBytes(storageRef, input?.files![0]).then((snapshot) => {
          console.log(snapshot);
          console.log('Uploaded a blob or file!');
        });
      }

CodePudding user response:

There is another thing you have to do. It's covered in the documentation. Use getDownloadUrl().

getDownloadURL(ref(storage, 'images/stars.jpg'))
  .then((url) => {
    // `url` is the download URL for 'images/stars.jpg'
  }

You can only do this after the upload fully complete.

  • Related