Reputation: 6477
I have an upload form in rails. I'd like to do some pre-processing on the uploaded file before other logic takes over.
When I print out the entire params
I see that my uploaded file's data in params as:
"logo"=>#<ActionDispatch::Http::UploadedFile:0x007fbf2964d7b0 @original_filename="huddle-house.JPG", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"merchant[logo]\"; filename=\"huddle-house.JPG\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/rl/t02q9t1j3m53ktcqx_dj6zmc0000gn/T/RackMultipart20111222-605-1q58pp5>>,
How can I access the tempfile
that's in that ActionDispatch?
I've tried the following and none of these work:
params[:logo][:tempfile]
params[:logo].tempfile
Upvotes: 0
Views: 267
Reputation: 230286
Well, assuming params[:logo]
returns that ActionDispatch
object, you could try this:
params[:logo].instance_variable_get(:@tempfile)
Upvotes: 1