Non-form-based file upload

Hi all,

I have a relatively newbie question regarding the processing of a file
upload from a source other than a Rails form. I’d like to upload a
file using a generic HTTP POST request that happens, in this case, to
come from a Java applet.

Each upload is a ZIP file that should be associated with particular
activity ID and document ID. The (multipart) form-based version works
fine, using the standard ActionView file_field helper and code like

path = “/files/” + params[:upload][:data].original_filename
root = “#{RAILS_ROOT}/public”
data = params[:upload][:data].read
File.open(path, ‘wb’) do |f|
f.write(data)
end

…in the controller.

What I’m wondering is how to handle the applet-based upload. I
figured it might help to have a custom route defined that the applet
would use, something like:

map.connect ‘activities/:activity_id/:document_id’,
:controller => ‘activities’, :action => ‘new_upload_applet’,
:activity_id => nil, :document_id => nil,
:requirements => {:activity_id => /\d/, :document_id => /\d/}

But then what? In the (hypothetical) new_upload_applet action, how do
I access the file data itself (stored under params[:upload][:data] in
the form-based version)?

Any help would be greatly appreciated. Thanks in advance,

Garrett