上传图片无法在生产模式下使用

问题描述 投票:1回答:1

上传图像在我的机器上运行良好,但在实时服务器上却无法运行。

这是本地主机上的参数:

{"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"}

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

我将nginx + Phusion Passenger用于实时服务器上的应用程序。

在实时服务器上,我选择一个图像,然后单击“提交”。 图像参数始终为零。

这是我的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天,但无法解决。 请帮我解决这个问题的方法。 谢谢

ruby-on-rails ruby nginx paperclip passenger
1个回答
0
投票

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

  config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
© www.soinside.com 2019 - 2024. All rights reserved.