4

I want to show uploaded image,but I got 403 error even I signin. Uploading work well, and downloadURl is ok. And I authenticated already (Upload success shows that I already signined) but I can't show uploaded image.

storage.child(file_name).put(event_image).then(function(snapshot) {
        console.log('Uploaded a blob or file!');
        var img_src = snapshot.downloadURL;
        $('img#uploaded').attr('src',img_src);
});
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Nomura Nori
  • 4,689
  • 8
  • 47
  • 85

1 Answers1

0

Use this link: https://firebase.google.com/docs/storage/web/download-files#download_data_via_url

storageRef.child('images/stars.jpg').getDownloadURL().then(function(url)     {
    // `url` is the download URL for 'images/stars.jpg'

   // This can be downloaded directly:
   var xhr = new XMLHttpRequest();
    xhr.responseType = 'blob';
    xhr.onload = function(event) {
    var blob = xhr.response;
    };
    xhr.open('GET', url);
    xhr.send();

     // Or inserted into an <img> element:
      var img = document.getElementById('myimg');
       img.src = url;
     }).catch(function(error) {
     // Handle any errors
});
Magellan
  • 1,224
  • 9
  • 16