Problem with Upload module

Valery Kholodkov valery+nginxen at grid.net.ru
Mon Aug 11 19:22:13 MSD 2008


As far as I understand ruby ideology, field name templates like
$upload_field_name.name cannot refer to a valid collection element.

Therefore you have to alter your config in the following way:

  location /upload {
    # Pass altered request body to this location
    upload_pass   /internalupload;

    # Store files to this location
    upload_store /tmp;

    # Set specified fields in request body
    upload_set_form_field "${upload_field_name}[name]" "$upload_file_name";
    upload_set_form_field "${upload_field_name}[content_type]"
"$upload_content_type";
    upload_set_form_field "${upload_field_name}[path]" "$upload_tmp_path";

    upload_pass_form_field "^commit$|^photo\[title\]$";
  }

And in your app change:

<%= file_field "photo", "uploaded_data" %>

to

<%= file_field_tag "photo", :id => "photo_uploaded_data" %>

Since I'm completely inexperienced in Ruby, there is still no guaranty
that this is going to work.

Also for security purposes declare your location /internalupload as
internal, so that no external requests to this location will be allowed:

  # Pass altered request body to a proxy
  location /internalupload {
    internal;
    proxy_pass   http://thin_cluster;
  }

> Hi Valery, I've attached the config.
>
> Very thanks for your time ;)


-- 
Best regards,
Valery Kholodkov






More information about the nginx mailing list