Problem with Upload module

Hi friends, I’m testing the Upload module, and I’ve a litle problem, the
fields of the form are not sent to my Rails app, here is my complete
config:

http://pastie.org/250944

Very thanks for your help ;).

Hi friends, I’m testing the Upload module, and I’ve a litle problem, the
fields of the form are not sent to my Rails app, here is my complete
config:

http://pastie.org/250944

Very thanks for your help ;).

I get following while opening your link:

---- Cut here ----
Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /250944.

Reason: Error reading from remote server
---- Cut here ----

Send your config as attachment please.

Hi Valery, I’ve attached the config.

Very thanks for your time :wink:

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 K. <

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;
}

Sorry, I just meant if it was valid with the upload module, since the
example you posted sent “photo” instead of “photo[uploaded_data]” as the
file? I misunderstood and thought you took out the bracketed params
because
of a limitation with the upload module,
-tieg

On Mon, Aug 11, 2008 at 1:58 PM, Valery K. <

I personally have absolutely no idea whether it is okay or not. This is
beyond my competence.

Very thanks Valery, it works very fine!

Regards.

No, there is no such limitation. You principally can specify:

upload_set_form_field “${upload_field_name}[name]” “$upload_file_name”;

etc. And get “photo[uploaded_data][name]” as a field name. I just don’t
know how is it going to be interpreted by Rails.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs