I get 413 Request Entity Too Large when uploading video file to Amazon S3

Jan Egil picture Jan Egil · Aug 3, 2017 · Viewed 8.3k times · Source

While uploading a video file to Amazon S3, the file hits 100% in uploading, then i get the response 413 Request Entity Too Large. How do i fix this so that i can upload video files to Amazon S3?

Im using Nodejs, Express, Heroku, Cloudflare and Amazon S3.

Answer

Mehmetali Saraç picture Mehmetali Saraç · Aug 3, 2017

What is your webserver nginx,apache ..etc ?

For nginx, you need to find the nginx.conf file.It should be in the

/etc/nginx/nginx.conf

open up with vi or nano

vi /etc/nginx/nginx.conf

find the client_max_body_size 2M

client_max_body_size 2M

you can edit this end done. M = Megabyte G = Gigabyte

if that doesnt work you need to change php.ini for that to work

This sets the maximum amount of memory in bytes that a script is allowed to allocate

memory_limit = 32M

The maximum size of an uploaded file.

upload_max_filesize = 2M

Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize

post_max_size = 3M

UPDATED FOR HEROKU

if you are using Express v4+ you can use

app.use(bodyParser({limit: '5mb'}));

but make sure this line is above

app.use(bodyParser.json());

otherwise it will not work