core icon indicating copy to clipboard operation
core copied to clipboard

Error: request entity too large

Open bryannbarbosa opened this issue 8 years ago • 11 comments

I need to upload an image through a request, but when I upload, I find the following message:

'request entity too large'

Although I have configured the file size that will be received, what can I do to solve the problem?

bryannbarbosa avatar Feb 06 '18 18:02 bryannbarbosa

Can u share the settings that you have changed and what's the file size?

thetutlage avatar Feb 07 '18 05:02 thetutlage

@thetutlage First of all, thank you.

This is the function I'm using:

async store({request, response}) {
  const profilePic = request.file('profile_pic', {
    types: ['image'],
    size: '60mb'
  })

  await profilePic.move(Helpers.tmpPath('uploads'), {
    name: `${new Date().getTime()}.${file.subtype}`
  })

  if(!profilePic.moved()) {
    return profilePic.error()
  }
  return 'File moved'
}

The size of image is 62,9 KB

bryannbarbosa avatar Feb 07 '18 19:02 bryannbarbosa

@thetutlage I need to develop an important project using AdonisJS and I have a deadline, if you can help me in the shortest possible time, I would be immensely grateful

bryannbarbosa avatar Feb 09 '18 23:02 bryannbarbosa

I tried your code and everything worked fine. Also the 60mb you have set is the current file max size. However you need to set the max payload size of request inside config/bodyParser.js file.

https://github.com/adonisjs/adonis-fullstack-app/blob/develop/config/bodyParser.js#L110

Also there was a typo that file.subtype has to be profilePic.subtype

thetutlage avatar Feb 10 '18 04:02 thetutlage

The real problem is that the content-type defined in the request was like "application / x-www-form-urlencoded", by disabling this in Postman, it ran perfectly, thanks!

bryannbarbosa avatar Feb 10 '18 05:02 bryannbarbosa

Ohhh yeah, it has to be multipart/form-data

thetutlage avatar Feb 10 '18 05:02 thetutlage

hi, i have issue like this. i tried upload pdf file (size 1-2Mb). the response always entity too large. what can I do to solve the problem?

this is my code const profilePic = request.file("profPic", { types: ["image", "pdf"], size: "5mb" });

emjea avatar Sep 24 '18 09:09 emjea

Hey @emjea! 👋

You need to increase the size limit in config/bodyParser.js. Also, make sure that your proxy configuration let you upload a big file.

RomainLanz avatar Sep 24 '18 10:09 RomainLanz

Hi @RomainLanz !

it's worked now. Thanks so much :)

emjea avatar Sep 25 '18 04:09 emjea

I have an issue but this time its from canvass dataURL. I already increase the limit to 100MB the error still display. I check the image size and its around 9KB only. Im using AJAX POST in submitting the data.

jbrhinalyn avatar Apr 06 '19 07:04 jbrhinalyn

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Mar 10 '20 23:03 lock[bot]