title: Ruby - Uploading a file using RestClient post
body: <p>I have a cURL that I am trying to translate into Ruby.</p>
  
  <p>the cURL is this:</p>
  
  <pre><code>curl -i -k -H "Accept: application/json" -H "Authorization: token" -H "Content-Type: image/jpeg" -H "Content-Length: 44062" --data-binary "gullfoss.jpg" http://www.someurl.com/objects
  </code></pre>
  
  <p>My Ruby code is this:</p>
  
  <pre><code>image = File.read('uploads/images/gullfoss.jpg')
  result = RestClient.post('http://www.someurl.com/objects',image,{'upload' =&gt; image, 'Accept' =&gt; 'application/json', 'Authorization' =&gt; 'token', 'Content-Type' =&gt; 'image/jpeg', 'Content-Length' =&gt; '44062'})
  </code></pre>
  
  <p>The Ruby code is giving me back a 400 Bad Request.  It's not a problem with Authorization or the other headers.  I think the problem lies with translating --data-binary to Ruby.</p>
  
  <p>Any help appreciated.</p>
  
  <p>Thanks,
  Adrian</p>