I coded this up to satisfy a need I had for an HttpClient that did a
form POST with Content-type: multipart/form-data .

It works on the one site I needed it to work on, and it fits in the
org.apache.commons.httpclient hierarchy, so I thought I'd donate it. 
Using it is the same as any other Method:

-----------

MultipartPostMethod postMethod = new MultipartPostMethod("/");
        
postMethod.addParameter("File", new File("/root/core"));
postMethod.addParameter("submitter", "[EMAIL PROTECTED]");

postMethod.setRequestHeader(authHeader);
        
int responseCode = postMethod.execute(state, conn);

-----------

It was coded similarly to the PutMethod, in that the file IS NOT
entirely read into memory before it is sent out.

FYI, if the site you're using it with requires Basic Authentication,
doing the postMethod.setRequestHeader(authHeader) manually will avoid
the file being uploaded twice (once to get back the 401, and then
once again successfully)

Do whatever you want with the code, it's all yours...

matt


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to