How can I read and write to Firebase Storage from within Cloud Functions for Firebase?

后端 未结 1 658
萌比男神i
萌比男神i 2020-12-11 05:15

I want to save a file from Cloud Functions for Firebase to Firebase Storage.

I also want to read the file from Firebase Storage to Cloud Functions for Firebase at a

相关标签:
1条回答
  • 2020-12-11 05:24

    Cloud Functions run in a fairly standard V8 Node.js container. So you can use the regular Node SDK for Google Cloud Storage to interact with your files.

    A snippet of code from the link:

    // Upload a local file to a new file to be created in your bucket.
    bucket.upload('/photos/zoo/zebra.jpg', function(err, file) {
      if (!err) {
        // "zebra.jpg" is now in your bucket.
      }
    });
    

    But really: just go to the link, it contains a better example than I'm willing to copy/paste here.

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