上传图片不适用于生产模式

时间:2012-11-29 16:36:30

标签: ruby-on-rails ruby nginx paperclip passenger

上传图片在我的计算机上运行良好但不能在实时服务器上运行。

这是localhost上的参数:

{"provider_source"=>{"photos_attributes"=>{"0"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0xaa23410 @original_filename="som_statenisland_netzero_school.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"provider_source[photos_attributes][0][image]\"; filename=\"som_statenisland_netzero_school.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20121129-4550-xbzsif>>, "description"=>""}, "1"=>{"description"=>""}, "2"=>{"description"=>""}}}, "utf8"=>"✓", "authenticity_token"=>"6cMwEI4lZreocgiOyJRdDfh2cGMcs85i28mMdsEWvog=", "remotipart_submitted"=>"true", "X-Requested-With"=>"IFrame", "X-Http-Accept"=>"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"}

我在实时服务器上安装了图像magick。

我在实时服务器上使用nginx + Phusion Passenger作为我的应用程序。

在Live服务器上,我选择一个图像并点击提交。图像参数总是零。

这是我的nginx配置:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    passenger_root /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.18;
    passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p180/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        root /srv/www/rails/bbz_dev;
        passenger_enabled on;

        }
}

我不知道为什么会出现这个问题。我尝试解决它2天但我不能。请帮我解决这个问题。谢谢

1 个答案:

答案 0 :(得分:0)

在production.rb中,你有这个吗?

  config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx