I have a js API (AWS API Gateway + Lambda) that receives form data containing a file (png/jpeg/obj). It takes the file and uploads it to IPFS using Pinata. The problem is that when I hit the Pinata api /pinFileToIPFS the resulting hash isn't viewable in the browser (example), it just instantly downloads. When I hit the same endpoint using postman it is viewable in the browser (example). I want Opensea to pick up on NFT metadata and it doesn't seem to work unless the image is viewable. I'm using lambda-multipart-parser in order to parse the form data from the lambda event body and I'm getting a result like this:
{
files: [
{
content: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 01 87 00 00 01 aa 08 06 00 00 00 e0 2c 88 96 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 65 00 ... 6342 more bytes>,
filename: 'my-img.png',
contentType: 'image/png',
encoding: '7bit',
fieldname: 'file'
}
],
}
I then do the following conversion to prepare the data for the Pinata request:
import FormData from "form-data";
import parser from "lambda-multipart-parser";
import { Readable } from "stream";
const stream = Readable.from(request.files[0]["content"]);
stream.path = request.files[0]["filename"];
let pinataData = new FormData();
pinataData.append("file", stream);
I'm assuming it has to do with the way I'm formatting the image readable data, but I've run out of things to try. Any help would be appreciated!