[英]Save multiple files to Firebase storage using cloud functions
I am looking around to find a way on how to be able to upload multiple images/files to Firebase Storage using functions but I am not able to find any example. 我正在四处寻找如何使用功能将多个图像/文件上传到Firebase Storage的方法,但是找不到任何示例。 Actually I found an similar example but the the files limit is only 10mb and that is not enough for my case where user can post up to 15HD images.
实际上,我找到了一个类似的示例,但是文件限制仅为10mb,对于用户最多可以发布15HD图像的情况而言,这还不够。
I am looking forward just for a hint, example somewhere on how could I archieve this using functions. 我期待一个提示,例如如何使用函数归档的示例。
Thank you in advance, Cheers 预先谢谢你,干杯
It would be helpful to see what you have tried so far, but here's simple example of how this might look in a node module. 查看到目前为止您已经尝试过的内容将很有帮助,但这是一个简单的示例,说明了它在节点模块中的外观。 It may be different using cloud functions, but it should at least point you in the right direction:
使用云功能可能会有所不同,但至少应为您指明正确的方向:
const Storage = require('@google-cloud/storage');
const storage = Storage({
projectId: firebaseProjectId,
credentials: serviceAccountCredentials
});
const bucketName = 'someFirebaseBucket';
const uploadFile = (filename) => {
return storage
.bucket(bucketName)
.upload(filename)
};
const uploadMultipleFiles = (fileList) => {
const uploads = fileList.map(uploadFile)
Promise.all(uploads)
.then(results => {
// handle results
})
.catch(error => {
// handle error
})
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.