Rails 文件上传大小限制 [英] Rails file upload size limit

查看:86
本文介绍了Rails 文件上传大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道在使用Passenger/mod_rails 运行Rails 应用程序时限制文件上传大小的好的解决方案.应立即拒绝该请求,以免文件传输到服务器.

Does anyone know a good solution to limit the file upload size when running a Rails application with Passenger/mod_rails. The request should immediately be declined, so that the file doesn't get transferred to the server.

到目前为止我找到的解决方案都描述了如何修补 Mongrel 以实现限制,但我必须在此应用程序中使用乘客.

The solutions I've found so far all describe how to patch Mongrel to implement a limitation, but I have to use passenger with this application.

推荐答案

或者,如果您使用 nginx 和乘客,请添加服务器块:

Or if you're using nginx with passenger, add in the server block:

server {
  client_max_body_size 100M;
}

http://wiki.nginx.org/NginxHttpCoreModule#client_max_body_size

这篇关于Rails 文件上传大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆