如何从Fire Elements的Cloud Functions中读取和写入Firebase存储? [英] How can I read and write to Firebase Storage from within Cloud Functions for Firebase?

查看:127
本文介绍了如何从Fire Elements的Cloud Functions中读取和写入Firebase存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文件从用于Firebase的云端功能保存到Firebase存储。我还想从Firebase存储转换为Firebase云端功能中的文件,以后的时间。



我找不到任何相同的示例。有人可以帮忙吗?

解决方案

Cloud Functions运行在相当标准的V8 Node.js容器中。因此,您可以使用常规的 Google云端存储节点SDK 与您的文件进行交互。



链接代码片段:

  //将本地文件上传到要在您的存储桶中创建的新文件。 
bucket.upload('/ photos / zoo / zebra.jpg',函数(err,file){
if(!err){
//zebra.jpg现在处于你的桶。
}
});

但真的:只要到链接,它包含一个比我愿意复制更好的例子/粘贴在这里。


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?

解决方案

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.

这篇关于如何从Fire Elements的Cloud Functions中读取和写入Firebase存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆