Sunday, April 05, 2009

curl and imageshack - how to upload

I finally figured out how to correctly upload to imageshack.us using curl. It is documented all over, but I wanted to show a simple command line that works. Note that when using "xml=yes", you get a nice formatted xml file as an output from imageshack, and you don't have to parse the output that keeps changing. I've noticed that a few programs try and parse "direct link to image" which is a mistake that I have made previously. From a windows command line you can use:

curl -F "fileupload=@c:\temp\testimage.jpg" -F "xml=yes" -H "Expect:" -o "c:\temp\output.xml" imageshack.us/index.php

You can also put this into a config file and upload using curl's --config option. Notice that there are no quotes around the fileupload line. I made the mistake of using quotes, and it kept failing.
configfile.txt

--form fileupload=@
c:\temp\testimage.jpg
--form "xml=yes"
--header "Expect:"
--output
c:\temp\output.xml
--url = "imageshack.us/index.php"

Then use the command:
curl --config
configfile.txt



No comments: