PinataCloud / Pinata-SDK

Official SDK for the Pinata IPFS service
MIT License
273 stars 67 forks source link

Question: When using boiler plate file upload, what goes in "MyCustomName" ? #149

Closed bigBagBoogy closed 1 year ago

bigBagBoogy commented 1 year ago

I copied the example file in your docs for uploading a file, I change to the correct image in my files, However I now get:

ReferenceError: MyCustomName is not defined

I do not have the knowledge as to what goes here. Anything I put in that place comes back as undefined.

Tnx in advance for your reply!

rommel-pinata commented 1 year ago

Hello @bigBagBoogy Could you post your code?

bigBagBoogy commented 1 year ago

Hello rommel-pinata, Thank you for your reply. Here is my code:

const pinataSDK = require("@pinata/sdk")
const pinata = new pinataSDK(
    "235*****cfd",
    "793***db4"
)

const fs = require("fs")
const readableStreamForFile = fs.createReadStream("./faceTreeWhite.png")
const options = {
    pinataMetadata: {
        name: MyCustomName,
        keyvalues: {
            customKey: "customValue",
            customKey2: "customValue2",
        },
    },
    pinataOptions: {
        cidVersion: 0,
    },
}
pinata
    .pinFileToIPFS(readableStreamForFile, options)
    .then((result) => {
        //handle results here
        console.log(result)
    })
    .catch((err) => {
        //handle error here
        console.log(err)
    })

and this is the error message:


yarn run v1.22.19
warning package.json: No license field
$ ****/node_modules/.bin/hardhat run utils/uploadToPinata3.js

/****/utils/uploadToPinata3.js:11
        name: MyCustomName,
              ^
ReferenceError: MyCustomName is not defined
    at Object.<anonymous> (****/utils/uploadToPinata3.js:11:15)```

greetings, Maarten
bigBagBoogy commented 1 year ago

nevermind I'll use thirdweb.