Reputation: 2493
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 later time.
I couldn't find any example for the same. Can someone help?
Upvotes: 8
Views: 7203
Reputation: 600006
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.
Upvotes: 10