On Sat, Nov 29, 2008 at 09:29:55PM +1100, e deleflie wrote:
> 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
> 

Okay, this is a good start. Let's just do string keys for the fields
(like `download` does for the :header option) and we can split the
auth into :username, :password and :auth.

  upload_form "http://www.stevex.net/dump.php";,
              :fields => {'person[name]' => "Johnny"},
              :username => "name", :password => "pwd" do |dump|
    # ...
  end

And `upload` would be used for strictly sending a raw body or File
to a url.

  upload "/tmp/body.post", :to => "http://www.stevex.net/dump.php";

> 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

Yeah, okay, these are good, too.  This is productive.

_why

Reply via email to