How to pass File to Firebase Functions

cor*_*ese 1 node.js firebase reactjs google-cloud-functions pinata

I'm trying to pass a file (image) from my Reactjs app to Firebase Functions to then upload it to Pinata using their Node.js sdk but my cloud function keeps returning: ERR_INVALID_ARG_TYPE

Is it possible to pass a file to Firebase Functions?

I need to eventually convert it to a readable stream to use Pinata.

Image file: 在此输入图像描述

Fra*_*len 5

Callable Cloud Functions仅接受 JSON 类型,因此您无法将File对象传递给它们。

能做的是:

  • 从客户端的文件中读取字节,然后传递byte[](JSON 类型)或将其作为 base64 编码的字符串传递。
  • 或者您可以通过 Firebase 将文件写入 Cloud Storage,然后将该文件的路径传递给您的 Cloud Function