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.
2
Answers
Used Frank van Puffelen's advice and first uploaded the file to Firebase Storage, then downloaded it in my Firebase Function, then converted the file to an array buffer.
Download from Google Cloud Storage
Convert to Array Buffer
Then you can pass the Array Buffer to IPFS or arweave
Callable Cloud Functions only accept JSON types, so you can’t pass a
File
object to them.What you can do is:
byte[]
(which is a JSON type) or pass it as a base64 encoded String.