Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 640
Jan Egil Avatar asked Aug 03 '17 13:08

Jan Egil


2 Answers

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

like image 141
Mehmetali Saraç Avatar answered Sep 22 '22 18:09

Mehmetali Saraç


Since you mentioned Cloudflare, that is likely the culprit. They enforce a maximum upload size of 100MB for their free plan. Since you’re using AWS S3, you can generate pre-signed URLs and upload directly to your S3 bucket instead of going through your server.

like image 36
ezekg Avatar answered Sep 23 '22 18:09

ezekg