hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "madhu nair" <madhu741...@gmail.com>
Subject Issue with uploading multiple files using MultipartRequestEntity
Date Mon, 11 Feb 2008 04:18:44 GMT
Hi,
Can the MultipartRequestEntity object be used to upload multiple files at a
time to a url. I seem to have some issues with this. My code works fine for
a single file but then for the 2nd file the same code fails. I am using the
following classes:-
PostMethod

FilePart

This is how I create the filepart object:-

part = *new* FilePart("filename." + (i+1), *new*ByteArrayPartSource(attachment.
attachmentName,attachment.data));

part.setTransferEncoding(*null*);



parts.add(part);

multiParts = parts.toArray(*new* Part[]{});

attach.setRequestEntity(*new* MultipartRequestEntity(multiParts,
attach.getParams()));

code = *httpclient*.executeMethod(attach);

html = attach.getResponseBodyAsString();

I have multiple such file parts added to the parts list before passing it to
the MultipartRequestEntity object. i am not changing the content-type and am
using the default of "application/octet-stream".

Can anyone tell me what is wrong or give me the code snippet to upload
multiple files at a time ?

Thanks for your help.

Madhu

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message