Web3API.storage (IPFS) size question

I was trying to test the spotify clone. And when implementing found an issue with the upload through API.
It gave me this error : ERR_FR_MAX_BODY_LENGTH_EXCEEDED
image

When asked in Discord mods told me there is 5mb limit for uploading files using API, which is not enough for any project i guess. I was trying to upload just 30MB.

So, then i decided to upload files using saveIPFS(), but faced an issue that I can’t upload multimple files to same IPFS CID, so each file is going to have different directory which is again not conviniet.

So, the question is - What do I do wrong? :slight_smile: If nothing, then maybe we can think of increasing API limits from 5mb? On smaller files it works like a charm! Indeed amazing tool!

Thanks everyone!
Twitter @axrisi

Hi,

I don’t think that the limit is of 5MB for uploadFolder
https://docs.moralis.io/moralis-dapp/web3-api/ipfs-storage-new#uploadfolder-new

that limit of ~5MB was a long time ago, now it should work with bigger sizes, you shouldn’t get that error for 5MB

Here is code. I removed API key. At time runnin script - it’s there. It uses ipload.folder as you can see. Still gives me that error. works perfectly fine with less than 5mb.

let fs = require(“fs”);

let axios = require(“axios”);

let media = [“01.mp3”];

let ipfsArray = [];

let promises = [];

for (let i = 0; i < media.length; i++) {

promises.push(

new Promise((res, rej) => {

  fs.readFile(`${__dirname}/export/${media[i]}`, (err, data) => {

    if (err) rej();

    ipfsArray.push({

      path: `media/${i}`,

      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);

});

});

P.S. just before publishing this comment, I checked what’s the top limit and it’s 7.5mb worth of files. It wouldn’t take any more.

Did you try to set the limit for axios? I remember something about setting limit infinity for axios in particular.

Brother! You saved the day!
Worked like magic :slight_smile:

Case closed! :slight_smile:

forgot to say thanks! :slight_smile:

1 Like

Hey!
I’ve been trying to so the same thing as 5 days ago and total size is the same or maybe even lower but still gives me this error. So what else can I actually do? and maybe someone can test using same moralis IPFS uploader for files of 50-100mb in one go. Maybe the problem is not size but length when it transforms toString.

data: ‘\r\n’ +
’413 Request Entity Too Large\r\n’ +
‘\r\n’ +

413 Request Entity Too Large

\r\n’ +

nginx\r\n’ +
‘\r\n’ +
‘\r\n’

},
adapter: [Function: httpAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: ‘XSRF-TOKEN’,
xsrfHeaderName: ‘X-XSRF-TOKEN’,
maxContentLength: Infinity,
maxBodyLength: Infinity,
env: { FormData: [Function] },
validateStatus: [Function: validateStatus],
headers: {
Accept: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘X-API-KEY’: ‘my api key’,
‘User-Agent’: ‘axios/0.27.2’,
‘Content-Length’: 74680464
},
method: ‘post’,
url: ‘https://deep-index.moralis.io/api/v2/ipfs/uploadFolder’,
data: '[{“path”:“media/12”,“content”:"UklGRtJeAABXRUJQVlA4IMZeAA

Wha teas the content length when it worked?. It looks like now it is close to 74MB

I know it says here 74mb, but it’s weird. cause it’s only image

The data is not sent in binary format. It is converted to base64 that increases the size before it tries to upload it. That is why the size that tries to upload is not the same size as the file has on disk.