hello,
I am using httpclient with a servlet and want to upload
a file.
I know that it is no good idea to mix "usual post" and "multipart/form-data".
The server has to get a message that let 'him' know an
upload is comming : e.g.
//client
FilePart fPart = new FilePart(file.getName(), file);
StringPart sPart = new StringPart("MESSAGE", "UPLOAD");
Part[] parts = {sPart, fPart};
postMethod.setRequestEntity(
new MultipartRequestEntity(parts, postMethod.getParams()));
The servlet use org.apache.commons.fileupload to parse the files.
The usual way to get a message is not working with StringPart anymore
request.getParameter("MESSAGE");
I only found a solution like
if(reqeust.getContenetType().equals( "multipart/form-data"))
// parse all form data from the upload and get the message
The wire logs from the httpClient looking a bit confuse
with "multipart/form-data".
I don't know if it has something to do that I forgot to
set something anywhere or if it is not possible to get
the message from a StringPart with request.getParameter.
------------------------------------------
some logs without setting anything
/2006-12-13 19:5?:??,??? DEBUG [AWT-EventQueue-0]// -- delete this
httpclient.wire.header: >> "Content-Type: multipart/form-data;
boundary=hT1l_nM1s2s3ba1eIkHmnKPtH2Q5Dyj8c[\r][\n]"
httpclient.wire.header: >> "[\r][\n]"
httpclient.wire.content: >> "--"
httpclient.wire.content: >> "hT1l_nM1s2s3ba1eIkHmnKPtH2Q5Dyj8c"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "Content-Disposition: form-data; name="
httpclient.wire.content: >> """
httpclient.wire.content: >> "MESSAGE"
httpclient.wire.content: >> """
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "Content-Type: "
httpclient.wire.content: >> "text/plain"
httpclient.wire.content: >> "; charset="
httpclient.wire.content: >> "US-ASCII"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "Content-Transfer-Encoding: "
httpclient.wire.content: >> "8bit"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "UPLOAD"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "--"
httpclient.wire.content: >> "hT1l_nM1s2s3ba1eIkHmnKPtH2Q5Dyj8c"
--------------------------
if I am add setContentChuck(true)it is a bit better
httpclient.wire.content: >> "Content-Disposition: form-data;
name="MESSAGE"[\r][\n]"
httpclient.wire.content: >> "Content-Type: text/plain; charset=US-ASCII[\r][\n]"
httpclient.wire.content: >> "Content-Transfer-Encoding: 8bit[\r][\n]"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "UPLOAD[\r][\n]"
--------------------------
I also tried the following, but it wasn't working:
//client todo: delete
StringPart sPart = new StringPart("", "MESSAGE=UPLOAD");
logs :
httpclient.wire.content: >> "MESSAGE=UPLOAD[\r][\n]"
maybe there is a better way to transfer a message to let the
server know an upload is comming? I am new in this stuff.
thanks for help,
bastian
--
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]