Register now and start sharing your code snippets.
-->

How to perform a file upload (multipart post) with Ruby

Ruby posted 9 months ago by christian

You have at least three options:

  1. The curb gem
  2. The multipart-post Net:HTTP extension
  3. Calling curl from Ruby with, for example, Open3.
       1  Open3.popen3('curl  <and your parameters>') do |input, output, error|
       2      # do something
       3      end
    
Tagged post, multipart, curl, ruby

Login to protected resources with curl

Shell Script (Bash) posted about 1 year ago by christian

Cookies are stored and retrieved from cookies.txt. Post data is set using the data switch:

   1  curl --cookie cookies.txt --cookie-jar cookies.txt --user-agent Mozilla/4.0 --data "user=xxxxx&password=xxxxx" http://www.com/login -v
   2  curl --cookie cookies.txt --user-agent Mozilla/4.0 http://www.com/protected/resource

Tagged curl, login, cookies