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

I want to save a file from cloud functions for Firebase to Firebase storage.

I also want to read a file from Firebase Storage to Cloud Functions for Firebase later.

I couldn't find a single example for this. Can anyone please help?

+3


source to share


1 answer


Cloud functions run in a fairly standard V8 Node.js container. This way, you can use the regular Google Cloud Storage Node SDK to interact with your files.

Code snippet from 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 follow the link, it contains a better example than I'm willing to copy / paste here.

+6


source







All Articles