我想将文件从 Cloud Functions for Firebase 保存到 Firebase Storage。
我还想稍后将该文件从 Firebase 存储读取到 Cloud Functions for Firebase。
我找不到任何相同的例子。有人可以帮忙吗?
最佳答案
Cloud Functions 在相当标准的 V8 Node.js 容器中运行。所以你可以使用常规的 Node SDK for Google Cloud Storage与您的文件交互。
链接中的代码片段:
// 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.
}
});
但实际上:只需转到链接,它包含一个比我愿意在此处复制/粘贴更好的示例。
关于firebase - 如何从 Cloud Functions for Firebase 中读取和写入 Firebase 存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42960506/