Keon Ramezani
Keon Ramezani

Reputation: 388

Heroku upload and script execution limitations

I am using PHP 5.4.12 on NGINX (custom buildpack) on Heroku. I'm running into issues when uploading images that are 1.5MB and greater in size. This is what I'm doing:

Any small files go through just fine. Anything bigger than a couple megs will just hang up during (what looks like) upload time. The same exact script works just fine on a different server.

I modified by php.ini file on Heroku, recompiled the slug, relaunched and reset the dynos. A phpinfo() call shows the increased upload limit, however the script still fails in the same way.

I understand Heroku is supposed to have a 30 second script execution limit, however, the way I see it, PHP upload happens prior to the script beginning execution in the first place.

I was originally trying to execute the upload script from a different server, however, since I'm making an Ajax request to the upload script, I run into CORS (cross origin resource sharing) limitations, and I don't like CORS workarounds since some browsers don't obey.

Any ideas how I can allow users to upload an image greater than 1.5MB, run my cropping/masking script on the image and then store the image somewhere (Amazon S3, for example)? Perhaps someone knows of a way to upload directly to Amazon, edit the images on EC2 and then move to S3? Thanks!

PS, looking for a Flash-free solution, as I'm trying to be mobile friendly.

Upvotes: 3

Views: 1202

Answers (1)

Nitzan Shaked
Nitzan Shaked

Reputation: 13598

Your scripts start executing before the file upload is complete. Carefully read Heroku documentation on limits and routing, and you'll see that the time POST body is read by your script, and the routers limit that and limit the minimum rate at which you can read.

Heroku recommends uploading large files directly to S3: https://devcenter.heroku.com/articles/s3#file-uploads

Upvotes: 0

Related Questions