You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by madhu nair <ma...@gmail.com> on 2008/02/11 05:18:44 UTC
Issue with uploading multiple files using MultipartRequestEntity
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
Re: Issue with uploading multiple files using MultipartRequestEntity
Posted by Roland Weber <os...@dubioso.net>.
madhu nair wrote:
> 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 haven't heard of a problem with that yet, but I'm not sure it
was tried either. Could you be a wee bit more specific about the
"code fails" part? Exception? Error response from the server?
Endless loop? Blocked forever?
Providing a reproducible test case based on our test framework
would raise your chances that a developer will look into it.
cheers,
Roland
> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org