IPFS upload with uploadFolder -> data undefined

Let me know if you maybe will find solution

maybe you try to read more files than you have in your folder, here it tries to read close to 270 files.
You could print file path before trying to read it, and when that data is undefined.
You could also skip ipfsArray.push when data is undefined.

Tried with less, still failing. Do you know maybe how the code will look like if i skip ipfsArray. push? what would be the other way to upload 270 images to ipfs , if not pushing them in array?

I could make an equivalent code in Python if you want, Iā€™m not expert in js syntax, but it should be a simple if there.
You could also decrease that number to 10 instead of 270, and make sure that you have 10 images in your folder

it does work with 10 :thinking:

mine still did not work with 10

if you try with 2 or 3 it works?

no, same error happens even with 1.

and you have those image files in that directory like /export/1.png, /export/2.png?
what is the size of those two .png files in your case?

yes, obviously changing the name to the actual name of the folder in the same directory of the images I want to do this process under. They are between 60-65 kb each

In my case /unminted/1.png, /unminted/2.png, etc

and did you also changed in this line instead of export to unminted?

Correct, it is changed

can you double check that you are accessing the right files, could you print the size of those files in that loop before reading from them with fs.readFile(${__dirname}/export/${i}.png, (err, data) => {?

I am experiencing the same issue.

Root Issues: I encountered 2 errors, 1) caused by the HEX generator (toString(16), changed it to toString() to resolve, and 2) caused by file size, ranging from 1MB to 19MB file sizes.

After changing HEX generator, my code works fine with small PNG files and uploads all 33 files. When I use production images, large JPG, files the code fails.

Solutions Tried: Everything listed on the internet, set maxBodyLength/maxContentLength/maxRedirects to Infinity/Infinity/0, and large numbers for values, all to no avail. Even downgraded version of axios, all the same result, error persists.

Can someone solve this issue for uploading files to IPFS?

Some solutions seem to suggest the value max size is limited at the server ie moralis/ipfs, or may even be memory/buffer related. Works fine with small files, chokes on large files.

Error Message: CustomError {message: ā€˜Request body larger than maxBodyLength limitā€™, config: {ā€¦}, request: RedirectableRequest, response: undefined, isAxiosError: true, ā€¦}

We will have to improve that uploadFolder for IPFS files

please same data undefined here :frowning:

usually it could be because of trying to upload a missing image (that is not present on disk), or trying to upload more than 5MB in size

1 Like

Hi this is the error i am having when I try to run this code:

PS C:\Users\antho\OneDrive\Code> node images.js
C:\Users\antho\OneDrive\Code\images.js:15content: data.toString(ā€œbase64ā€)
^

TypeError: Cannot read properties of undefined (reading ā€˜toStringā€™)
at ReadFileContext.callback (C:\Users\antho\OneDrive\Code\images.js:15:31)

that error says that data is undefined, that could mean that it didnā€™t read any data because it didnā€™t find a file to read from