如何通过云功能将图像存储在 Firebase 存储中

How to store an image on Firebase Storage from a Cloud functions

我希望能够在 Firebase 存储上添加安全规则,以控制和防止从应用程序导入图像。为此,我希望能够将图像或音频文件发送到 Cloud Functions,以便它自己处理上传,而不是从 Front 部分处理。

因此我的问题如下:知道我们已经可以直接从 Flutter 应用程序存储图像,是否可以从 Cloud Functions 做同样的事情?

在 Cloud Functions 等服务器端环境中,您可以使用 Firebase Admin SDK 与 Cloud Storage 进行交互。在这种情况下,您最终将使用 pre-initialized version of the Node.js SDK for Cloud Storage.

根据这些知识,我们可以搜索 Node.js SDK for Cloud Storage upload file,这会导致:

  • How to store files in firebase using node.js 用于上传文件
  • 获得签名 URL