简体   繁体   English

使用云功能将多个文件保存到Firebase存储

[英]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.

相关问题 无法使用Firebase功能删除Google Cloud Storage文件 - Cannot delete Google Cloud Storage files using Firebase Functions 我可以通过 Firebase Cloud Functions 压缩 Firebase 存储中的文件吗? - Can I zip files in Firebase Storage via Firebase Cloud Functions? 使用 Firebase Cloud Functions 将文件上传到 Firebase 存储时出错 - Error while uploading file to Firebase Storage using Firebase Cloud Functions Firebase存储错误的云功能 - Cloud Functions for Firebase Storage Error 使用Cloud Functions REST API请求将文件存储在Firebase存储中 - Store file in Firebase Storage using Cloud Functions REST API request 使用下载 url 和 Cloud Functions 从 Firebase 存储中删除文件 - Delete a file from firebase storage using download url with Cloud Functions Firebase存储和云功能:如何从url加载内容并将其保存到存储中? - Firebase Storage and Cloud functions: how to load content from url and save into storage? 使用云功能创建pdf文件并将其上传到firebase存储? (可以上传本地文件,但不能从云功能上传) - Create and upload pdf file to firebase storage using cloud functions? (can upload locally file, but not from cloud functions) 从 REST API 获取图像并将其上传到 Firebase 云存储使用 Z035489FF8D324159ZEEA 功能 Cloud Storage - Getting image from REST API and uploading it to Firebase Cloud Storage using Firebase Cloud Functions 使用http cloud云功能从Firebase云存储下载文件时,没有此类文件或目录 - no such file or directory when downloading a file from firebase cloud storage using http cloud cloud functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM