> On Sat, Nov 29, 2008 at 02:49:12PM +1100, e deleflie wrote:
>> I'm using Mechanize to good effect now, but I would have fallen over
>> if this was built-into the 'download' method (although the name
>> 'download' isn't so appropriate).
>
> I would love to. And it should be called 'upload' in that case. I
> just haven't done it because a really smashing idea hasn't struck me
> yet. Do you have anything specific you'd like to suggest?

well, there's the URL, the REST verb, the field names and their
values, file fields and their values ... and basic authentication.

maybe something like this... (note: I'm a Ruby newbie)

     # note: I use :"foo[bar]" because that's how Rails likes to see
field names.
     fields = { :"person[name]" => "Johny", :"person[photo]" =>
File.new("/bla/bla/johny.jpg") }

     download "http://www.stevex.net/dump.php";, :method => "POST",
:fields => fields, :basic_auth => ["name", "pwd"] do |dump|
          ...
     end

where:
- in the fields hash, if the value of a field is a File object then it
is automatically considered to be a file field
- if there is a file field in the fields hash, then the form is
automatically posted with an enctype of multipart

... that would just be tooooo easy. (I'm not sure if there's other
stuff to consider WRT to mime types of files or whatever ... )

Etienne

Reply via email to