标签: pinata

在 Firebase 函数中的 /tmp 中写入文件不起作用

我正在编写一个 Firebase 函数,该函数使用express. 当端点被调用时,它需要从外部API下载图像并使用该图像进行第二次API调用。第二个 API 调用需要将图像作为 readableStream. 具体来说,我正在调用Pinata APIpinFileToIPFS的端点。

我的 Firebase 功能用于axios下载图像并将fs图像写入/tmp. 然后我用来fs读取图像,将其转换为 areadableStream并将其发送到 Pinata。

我的代码的精简版本如下所示:

const functions = require("firebase-functions");
const express = require("express");
const axios = require("axios");
const fs = require('fs-extra')
require("dotenv").config();
const key = process.env.REACT_APP_PINATA_KEY;
const secret = process.env.REACT_APP_PINATA_SECRET;
const pinataSDK = require('@pinata/sdk');
const pinata = pinataSDK(key, secret);
const app = express();

const downloadFile = async (fileUrl, downloadFilePath) => {
  try { …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions axios pinata

5
推荐指数
1
解决办法
604
查看次数

How to pass File to Firebase Functions

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: 在此输入图像描述

node.js firebase reactjs google-cloud-functions pinata

1
推荐指数
1
解决办法
650
查看次数