Problem getting download URL from Firebase Storage


Gjison Giocf

I'm trying to loop through the files in my game folder on firebase and display them on a page in a list format.

// Create a reference under which you want to list
var listRef = firebase.storage().ref("games/");;

// Find all the prefixes and items.
listRef.listAll().then(function(res) {
  res.prefixes.forEach(function(folderRef) {
    // All the prefixes under listRef.
    // You may call listAll() recursively on them.
  });
  res.items.forEach(function(itemRef) {
    // All the items under listRef.
    console.log(itemRef)
    const p = document.createElement('a');
    p.textContent = itemRef.location.path;
    p.classList.add('col-lg-12');
    p.href = itemRef.getDownloadURL(); 
    console.log(p.href);
    

    document.getElementById('bar').appendChild(p);
    document.getElementById('bar').innerHTML+='<br />'

  });
}).catch(function(error) {
  // Uh-oh, an error occurred!
});


The problem is that I'm getting p.href=[object%20promise] instead of the file's download URL.

Doug Stevenson

The API documentation for getDownloadURL() says that it returns a promise resolved with the URL. It doesn't return the URL directly. You will have to use this promise to get the URL just as you would use the returned promise listAll().

itemRef.getDownloadURL().then(url => {
    console.log(url);
}

I recommend perusing the documentation for more information.

Related


Problem getting download URL from Firebase Storage

Gjison Giocf I'm trying to loop through the files in my game folder on firebase and display them on a page in a list format. // Create a reference under which you want to list var listRef = firebase.storage().ref("games/");; // Find all the prefixes and items

Problem getting download URL from Firebase Storage

Gjison Giocf I'm trying to loop through the files in my game folder on firebase and display them on a page in a list format. // Create a reference under which you want to list var listRef = firebase.storage().ref("games/");; // Find all the prefixes and items

Problem getting download URL from Firebase Storage

Gjison Giocf I'm trying to loop through the files in my game folder on firebase and display them on a page in a list format. // Create a reference under which you want to list var listRef = firebase.storage().ref("games/");; // Find all the prefixes and items

Problem getting download URL from Firebase Storage

Gjison Giocf I'm trying to loop through the files in my game folder on firebase and display them on a page in a list format. // Create a reference under which you want to list var listRef = firebase.storage().ref("games/");; // Find all the prefixes and items

Get download URL from Firebase Storage in Angular

Monther I'm trying to get the download URL after uploading a file to Firebase Storage, so far I've been able to upload the file, but for the URL, I've been getting undefined, this is my code: onFileChanged(event) { const file: File = event.target.files[0];

The URL to download from Firebase Storage is empty

Mobilize IT I am using Ionic 4 to upload images from camera to firebase storage. The upload works fine, but I'm having trouble getting the upload URL. My code looks like this: async getFromCamera(){ this.camera.getPicture({ destinationType: this.came

Unable to get download url from firebase storage

Pannan I can upload the image successfully but can't get the URL of the uploaded image Also with the recent changes to the method I would like to write a cleaner code than this. try { await FirebaseStorage.instance .ref()

Get download URL from Firebase Storage in Angular

Monther I'm trying to get the download URL after uploading a file to Firebase Storage, so far I've been able to upload the file, but for the URL, I've been getting undefined, this is my code: onFileChanged(event) { const file: File = event.target.files[0];

The URL to download from Firebase Storage is empty

Mobilize IT I am using Ionic 4 to upload images from camera to firebase storage. The upload works fine, but I'm having trouble getting the upload URL. My code looks like this: async getFromCamera(){ this.camera.getPicture({ destinationType: this.came

Download Firebase Storage URL not working

username I have an image uploaded to Firebase Storage, but I can't downloadURLsave it to the database. I've read a lot of posts on StackOverflow but nothing helps. The image is loaded into storage, but the error says the image doesn't exist. let image = self

Download Firebase Storage URL not working

username I have an image uploaded to Firebase Storage, but I can't downloadURLsave it to the database. I've read a lot of posts on StackOverflow but nothing helps. The image is loaded into storage, but the error says the image doesn't exist. let image = self

Firebase Storage Download URL Format

Cheap I'm wondering if there is a way to create a standard download URL for storage items on Firebase, so I don't have to retrieve the URL and then the image, as doing so is an expensive operation for both iOS and Android ? I've noticed so far that the only wa

How to remove query string from Firebase Storage download URL

Israel question: I need to be able to remove all link decorations from download URLs generated for images in Firebase Storage. However, when all link decorations are stripped, the currently generated link will return a JSON document of image metadata. content:

Error trying to get download URL from firebase-storage

Alec Janiak I've been trying to get the download URL of an image in my firebase storage, but it keeps throwing object-does-not-exist errors. Any clue what could be the problem? I'm sure the directories match and there is a profilePhoto.jpg file in the firebase

How to remove query string from Firebase Storage download URL

Israel question: I need to be able to remove all link decorations from download URLs generated for images in Firebase Storage. However, when all link decorations are stripped, the currently generated link will return a JSON document of image metadata. content: