views:

596

answers:

4

I am trying to post a large XML file to a web address by using curl in a shell script. I am posting the data using the '-F' option in curl. Whenever I post a file larger than 1024 bytes, the file gets cut off and only sends the first 1024. I've tried changing the "Expect:" header as suggested in another solution for PHP Curl, but it does not work.

Here is the command line I am using:

curl -F "xml=</fileoutput.xml" http://servername/page.html

As I said earlier, I've tried both -H "Expect:" -H "Expect: 100-continue"

Neither work. Please help!

+1  A: 

Is it possible that the web address itself has this limitation? Have you tried posting the same file manually via a web browser?

lod3n
Good thought! I just tested this out and was able to post a large >1k file to it directly via Firefox.
adamweeks
A: 

I think you need to use -d instead of -f ?

-d seems to post the data. As Sab pointed out GET has a very small maximum size, you must post the file and to do this you must use -d rather than -f.

Look here.

Toby Allen
+3  A: 

According to the man page the -F option does do POST so it doesn't look like it's a GET issue. The man page also says to prefix the file with an @ to use the file as the content so perhaps the command should be

curl -F xml=@http://servername/page.html
Troubadour
Thanks a ton! Even with my broken example (I fixed it and put the code tags around so it displayed properly) you got it!
adamweeks
+3  A: 

In order to poast a file you have to use the @ in front of the URL. I think Troubadour already mentions this, but it needs to be in quotes like:

 curl -F "xml=@http://servername/page.xml"

Also notice That I changed it to .xml as you said you were trying to post a large XML file, not a large HTML file.

Anthony
I accepted Troubadour's answer because my example did have quotes in it, but it wasn't shown because I didn't put it in a code block when asking it. Thanks for your help!
adamweeks