Problem with Upload module

Tieg Zaharia tieg.zaharia at gmail.com
Mon Aug 11 20:10:49 MSD 2008


This is more of a rails standard than a ruby standard, but shouldn't it be
okay to send the form field to the app server as
"photo[uploaded_data][name]", "photo[uploaded_data][content_type]", etc.
instead of just "photo[name]", "photo[content_type]", etc? The bracketed
values are usually used as attributes of a model, so you probably don't want
to take a chance of mixing up the model attributes with the uploaded data's
nginx attributes,
-tieg

On Mon, Aug 11, 2008 at 11:22 AM, Valery Kholodkov <
valery+nginxen at grid.net.ru <valery%2Bnginxen at grid.net.ru>> wrote:

>
> 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080811/68f9aa3c/attachment.html>


More information about the nginx mailing list