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.
Here is what I have tried:
curl -F "media[document]=@a.png" -F "media[name]=api" "http://example.com/medias/create.xml?api_key=123"
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)
what is the correct way to upload a file using cURL?
EDIT: adding -H "Content-Type: application/xml" to the above curl command make the server generate this error:
/!\ FAILSAFE /!\ Tue Jan 24 08:45:03 -0500 2012
Status: 500 Internal Server Error
#<REXML::ParseException: malformed XML: missing tag start
Line:
Position:
Last 80 unconsumed characters:
<:??OH?ɽ?H? ???g??yx~t????op?.$?????P&W ??"?
normally the XML is supplied using the -d argument. but I don't think files can be included in xml? maybe they can? idk.