Getting 413 Entity too large issue while uploading just 2MB file

Hello guys,

I am using reactJS code with moralis integration to upload the file to ipfs. When I am trying to upload 2 MB or more file it returning 413 entity too large issue. till 1 MB is file but after that is showing error. I also tried to change the client max body size at my nginx server but still same issue. Can you please help me to fix this issue.

Thank you

Hi @ahmad

Can you please share an example of your code which uploads the files to IPFS?

Hello @johnversus
sure, here is the code
const files = new Moralis.File(imagename, data);
await files.saveIPFS();
let imgurl = files.ipfs();

async function uploadImageOnIPFS(input) {
const data = input;
var imagetype = input?.type?.split("/")
let thumbnailImageUrl;
if (imagetype[0] == “video”) {
let props = { file: data, Moralis: Moralis };
thumbnailImageUrl = await GetVideoThumbnails(props);
thumbnailImageUrlRef.current = thumbnailImageUrl;
console.log(“thumbnailImageUrlRef----------->”, thumbnailImageUrlRef);
}

let imagename = Math.floor(Date.now() / 1000) + "." + imagetype[1];
const files = new Moralis.File(imagename, data);
await files.saveIPFS();
let imgurl = files.ipfs();
imagetypeRef.current = imagetype[0]
setMineType(imagetypeRef.current)
setimageFile(imgurl);
SavetoDraft(imgurl, imagetype);

}

Possible reason for the file limit could be due to a file limit added in your cloud code.

Can you verify in case if your cloud code has any beforeSaveFile trigger defined?

No, I haven’t used beforeSaveFile in my code anywhere, and I also checked the Moralis dashboard where no specific file size restriction has been set.

Ahh ok. Can you verify if the error 413 Entity too large issue is actually coming from your Moralis server?

You can check your browser network tab to find which request URL is throwing the 413 error.

sure,
here you can see the screenshot


Is it possible share the payload text of any failed request?

The content might be too lengthy for the forum, so maybe you can use pastebin.com to share the payload text.

sure,
here you can see the screenshot
payload


preview

Hi @ahmad

It seems like we haven’t made any changes recently to our IPFS limits. So the error which you are seeing from server might be an expected error. I would recommend compressing the file if possible.

Also please note that we are planning to move away from being IPFS storage provider. So if possible I would recommend migrating your app to different IPFS provider like Pinata.:pray:

Thank you so much for your valuable time, @johnversus