在Heroku上强制文件上传大小? [英] Enforce file upload size on Heroku?
问题描述
通常,我会限制Web服务器上的上传大小。但是用Heroku,有什么选择呢?我意识到我可以使用Flash上传器,但是我希望避免在客户端上使用Flash,如果可能的话。
解决方案Heroku将请求实体限制在一个很小的尺寸(30MB),并将所有的请求/响应周期限制在30秒。
默认情况下,Rails将文件上传到磁盘,然后将它们转换为Tempfile实例,然后将它们交给您的应用程序。
Got a Rails app on Heroku. I want to limit the size of a file upload if possible. The file is processed as a StringIO object, so the file contents will be processed in memory (have no need to write an intermediate file to a filesystem).
Ordinarily, I would limit upload size on the web server. But with Heroku, what options are there? I realize I could go with a Flash uploader, but I'm hoping to avoid requiring Flash on the client, if at all possible.
Heroku limits the request entity to some small size (30MB), and also limits all request/response cycles to 30s. Both are hard rules and must be lived with.
Rails by default spools file uploads to disk and translates them to Tempfile instances before handing them off to your application.
这篇关于在Heroku上强制文件上传大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!