title: How to upload a file using RestClient in Ruby?
body: <p>I am trying to upload a file in Ruby. Below is a sample of the REST call using curl.</p>
  
  <pre><code>curl --sslv3 -k -v -i -X POST \
  -H "Content-Type: multipart/mixed" \
  -H "Accept: application/json" \
  -H "Cookie: token=ABC; SESSION=13217EBA128F6ABC9E9AD095D602E4AB;" \
  -F "metadata=@input_payload_file.json; type=application/json" \
  -F "content=@MyFile.jpg; type=image/jpg"  \
  https://abc.com/attachments.
  </code></pre>
  
  <p>Can some please give me an equivalent of above in Ruby.
  I have tried the following, with no success.</p>
  
  <pre><code>$fileitem = File.new('C:\log.txt', 'rb');
  $fileinfo = '{"fileName":"log.txt", "resourceName":"log.txt",  "description":"Created using REST"}';
  
  response =RestClient::Request.execute(
     :method =&gt; :post,
     :url =&gt; $UploadURL,
     :headers =&gt; {:content_type =&gt; 'multipart/mixed', :accept =&gt; 'application/json'},
     :cookies =&gt; {:token=&gt; :"#{cust}",:SESSIONID =&gt; :"#{ssid}"},
     :payload =&gt; $fileinfo,
     :myfile =&gt; $fileitem
  )
  </code></pre>
  
  <p>Thanks in advance for any guidance.</p>
  
  <p>Ravi..</p>