Generate Download URL After Successful Upload

前端 未结 2 673
醉梦人生
醉梦人生 2021-01-14 20:35

I have successfully uploaded files to Firebase\'s storage via Google Cloud Storage through JS! What I noticed is that unlike files uploaded directly, the files uploaded thro

相关标签:
2条回答
  • 2021-01-14 21:11

    When using the GCloud client, you want to use getSignedUrl() to download the file, like so:

    bucket.file('photos/' + filename).getSignedUrl({
      action: 'read',
      expires: '03-17-2025'
    }, function(err, url) {
      if (err) {
        console.error(err);
        return;
      }
    
      // The file is now available to read from this URL.
      request(url, function(err, resp) {
        // resp.statusCode = 200
      });
    });
    
    0 讨论(0)
  • 2021-01-14 21:14

    You can either:

    a) Create a download url through the firebase console

    b) if you attempt to get the downloadurl programmatically from a firebase client, one will be created on the fly for you.

    0 讨论(0)
提交回复
热议问题