Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:49:05+00:00 2026-05-29T03:49:05+00:00

On the web side of things, I have two fields: name, and document. Document

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:49:05+00:00Added an answer on May 29, 2026 at 3:49 am

    If you want to create file from xml, you should format your xml to use data, either Base64 and/or CDATA, depending of your needs. Once you have a corretly formatted xml file, you just have to send it with curl.

    If you just want to upload file, you don’t need to use an xml interface. You can just call :

    curl -F "media[document]=@./a.png;type=image/png" -F "media[name]=api" "http://example.com/medias/
    

    For your authentification problem, if you still have it on this url (I do not encounter it on a new rails 3.2.1 fresh app), you can access it with a regular browser, get the cookie information and send it with curl. It means that you will add to your command :

    --cookie "csrf-param=authenticity_token" --cookie "csrf-value=XXXXXXX"
    

    Or use a convenient script to send all your current Firefox cookies from an host into curl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: We have two directories of Crystal Reports for both the web side of
I have a buddy who is building the web server side of things and
My app is working from the web side of things. I'd like to get
My question is pretty simple: If you have two web-application components: Server-side (secret-capable) code
In a web app which I'm building, I have two loosely related bits of
I've been experimenting with Adobe Flex recently. Being a long-time server-side web app developer,
i've been making web app's and working with various server side language like php,
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For
I'm working on a web app which is heavy on the client side, which
I have been working for two years in software industry. Some things that have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.