Hi , Iām trying to bulk upload NFTs Using IPFS folders (following this code https://github.com/MoralisWeb3/youtubā¦) and get a content:
data.toString(ābase64ā) > TypeError: Cannot read property ātoStringā of undefined. Any idea why that might be?
the code:
let fs = require("fs");
let axios = require("axios");
let ipfsArray = [];
let promises = [];
for (let i = 1; i<270; i++){
promises.push(new Promise( (res, rej) => {
fs.readFile(`${__dirname}/export/${i}.png`, (err, data) => {
if(err) rej();
ipfsArray.push({
path: `images/${i}.png`,
content: data.toString("base64")
})
res();
})
}))
}
Promise.all(promises).then( () => {
axios.post("https://deep-index.moralis.io/api/v2/ipfs/uploadFolder",
ipfsArray,
{
headers: {
"X-API-KEY": '',
"Content-Type": "application/json",
"accept": "application/json"
}
}
).then( (res) => {
console.log(res.data);
})
.catch ( (error) => {
console.log(error)
})
})