Firebase storage download the raw text I uploaded and not just the url

前端 未结 1 580
情深已故
情深已故 2021-01-16 21:19

I uploaded a raw String \'Test\' to the firebase storage using the sample provided here and it went through successfully.

But when I tried to \"downloa

相关标签:
1条回答
  • 2021-01-16 21:54

    The short answer is that in the Web Storage SDK you can only get a download URL that represents that data. You'll need to "download" the file using an XMLHttpRequest (or equivalent):

    storageRef.child('path/to/string').getDownloadURL().then(function(url) {
      var XMLHttp = new XMLHttpRequest();
      XMLHttp.onreadystatechange = function() { 
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
          var response = xmlHttp.responseText; // should have your text
      }
      XMLHttp.open("GET", url, true); // true for asynchronous 
      XMLHttp.send(null);
    }).catch(function(error) {
      // Handle any errors from Storage
    });
    
    0 讨论(0)
提交回复
热议问题