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?
From the navigation pane of the Firebase console, select Storage, then click Get started. Review the messaging about securing your Cloud Storage data using security rules. During development, consider setting up your rules for public access. Select a location for your default Cloud Storage bucket.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With