使用云功能将多个文件保存到Firebase存储 [英] Save multiple files to Firebase storage using cloud functions

查看:46
本文介绍了使用云功能将多个文件保存到Firebase存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在四处寻找如何使用功能将多个图像/文件上传到Firebase Storage的方法,但找不到任何示例.实际上,我发现了一个类似的示例但是文件限制仅为10mb,对于我最多可以发布15HD图像的情况而言,这还不够.

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. 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.

我期待一个提示,例如我如何使用函数来归档的示例.

I am looking forward just for a hint, example somewhere on how could I archieve this using functions.

预先感谢您,干杯

推荐答案

查看到目前为止您已经尝试过的内容会很有帮助,但这是一个简单的示例,说明了它在节点模块中的外观.使用云功能可能会有所不同,但至少应为您指明正确的方向:

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
    })
};

这篇关于使用云功能将多个文件保存到Firebase存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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