doujing1156 2013-08-26 20:34
浏览 141
已采纳

Heroku上传和脚本执行限制

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:

  • PHP Upload to Heroku (using iFrames and Ajax)

  • Crop, Resize and Mask the photo (using Imagick command line, convert and composite) on Heroku

  • Move the edited image to another server (because Heroku won't let you store things long-term unless they are git pushed to the server). Right now I'm using my test environment/server for this, but I'm sure I'll eventually move this onto S3.

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.

  • 写回答

1条回答 默认 最新

  • dongsiju1941 2013-08-26 23:00
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵