tags:

views:

345

answers:

4

As part of my Ant build process, I'd like to upload files to a webserver via HTTP Post. Ant only comes with an HTTP Get task. However, Ant Contrib seems to have an HTTP Post task. The problem is that it doesn't have any Basic Authentication (like get does) or any way to specify a file upload (despite what the docs say, "rawFile" is not part of the distro).

My question is: does Ant Contrib's Post task actually support what I want, but in a non-obvious way (perhaps I have to do it by hand)? Or is there some other way to do this?

A: 

Use the curl program called via an ANT exec task.

For curl examples read this answer

Mark O'Connor
That's what I was afraid of. I can do that, but it means that curl has to be installed, which means you can't just pull the build.xml out of svn and expect it to work. :(
paleozogt
I hear you, *and* to make you even more miserable using ANT plugins doesn't solve your problems unless you commit the 3rd party jars into subversion as well :-(
Mark O'Connor
A: 

There's a bunch of ant tasks based upon jakarta commons http client :

http://fikin-ant-tasks.sourceforge.net/

also providing a http post task with authentication.

When using ant with exec you will open a new process outside the java vm. IMO external processes should be avoided if possible.

Regards, Gilbert

P.S. : if fikin ant tasks / http post with basic authentication is broken i would prefer writing a java class or even my own task with jakarta commons, see jakarta commons http client , sample for basic authentication 2

so it may run in the same vm as ant or maybe in a forked java process
you'll find several examples for file upload with jakarta commons httpclient via google..

Rebse
I agree that using ant exec is ugly and I would much rather use pure java. However, the fikin ant tasks are broken for Basic Authentication.
paleozogt
A: 

There's an http post task in Antelope but it doesn't appear to support Basic Authentication. :/

paleozogt
A: 

There's also an AntLib in the ant sandbox here that claims to do HTTP get and post. However, its authentication is broken also.

paleozogt