【问题标题】:rails ajax file upload and nginxrails ajax 文件上传和 nginx
【发布时间】:2011-09-21 08:14:03
【问题描述】:

我正在使用 Rails 和 valums file-uploader 进行 ajax 上传。在开发中一切都完美无缺,但是在 linode nginx 上的生产中破坏了一切。 错误日志:

[ pid=2097 thr=3065629552 file=ext/nginx/HelperAgent.cpp:584 time=2011-06-23 09:47:06.714 ]: Uncaught exception in PassengerServer client thread:    exception: An error occured while sending the request body to the request handler: Broken pipe (32)    backtrace:
     in 'virtual void Passenger::Session::sendBodyBlock(const char*, unsigned int)' (Session.h:198)
     in 'void Client::sendRequestBody(Passenger::SessionPtr&, Passenger::FileDescriptor&, const std::string&, long unsigned int)' (HelperAgent.cpp:295)
     in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:510)
     in 'void Client::threadMain()' (HelperAgent.cpp:603)

2011/06/23 09:47:06 [error] 2134#0:
*13 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 94.76.87.38, server:
69.168.213.69, re$

在没有 javascript、使用 rails 3 和回形针的情况下,上传工作正常。数据库 - PostgreSQL。 我真的不擅长服务器端的东西,并寻求帮助如何解决这个问题。如果您需要更多信息,请发表评论。

【问题讨论】:

    标签: ruby-on-rails ajax file-upload nginx


    【解决方案1】:

    文件上传通过 StringIO 在 webbrick 上工作,但通过 Rack 在除 webrick 之外的所有设备上工作。这些更改为我解决了一个问题:

    -    file = request.body
    +    file = StringIO.new(request.body.read)
    

    【讨论】:

      猜你喜欢
      • 2013-01-17
      • 2010-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 1970-01-01
      • 2012-03-15
      相关资源
      最近更新 更多