IPFS upload with uploadFolder -> data undefined

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

Thatā€™s strange. Not sure what to do now because the directory with images is correct.

you could do some debugging, to see if you really access the directly that you expect