title: How can I upload a file to my ruby on rails app using curl CLI?
body: <p>On the web side of things, I have two fields: name, and document. Document is a file field, and name is just what the user wants to call the file in the app. </p>
  
  <p>Here is what I have tried:</p>
  
  <pre><code>curl -F "media[document]=@a.png" -F "media[name]=api" "http://example.com/medias/create.xml?api_key=123"
  </code></pre>
  
  <p>but I get an InvalidAuthenticityToken Error.
  This error only occurs when I try to upload a file / make a media object. The other API / xml commands work (the ones not involving files)</p>
  
  <p>what is the correct way to upload a file using cURL?</p>
  
  <p>EDIT:
  adding -H "Content-Type: application/xml" to the above curl command make the server generate this error:</p>
  
  <pre><code>/!\ FAILSAFE /!\  Tue Jan 24 08:45:03 -0500 2012
    Status: 500 Internal Server Error
    #&lt;REXML::ParseException: malformed XML: missing tag start
  Line: 
  Position: 
  Last 80 unconsumed characters:
  &lt;:??OH?ɽ?H? ???g??yx~t????op?.$?????P&amp;W ??"?
  </code></pre>
  
  <p>normally the XML is supplied using the -d argument. but I don't think files can be included in xml? maybe they can? idk.</p>