Uploading multiple files via HttpClient

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Uploading multiple files via HttpClient

dan0
I've put together code that can send one file at at time via HTTP. When I send more than one at a time the first file is processed but then the app hangs. My hunch is the problem is caused by the boundaries of the HTTP parts. Can anyone tell me:

1. If my hunch is correct, and if not what the actual problem is.
2. How to resolve the problem.

Below is the code I'm using to create the request entity:

try{
        for (File selectedFile : selectedFiles){
        Part[] parts = {new FilePart("imgFile[]", selectedFile)};
        post.setRequestEntity( new MultipartRequestEntity( parts, post.getParams() ) );
        ...
        ...
        }
} catch (Exception e) {

Following is the request entity header info:

--3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr
Content-Disposition: form-data; name="imgFile[]"; filename="Inbox_Msg_Display.GIF"
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary
--3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr--

--A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU
Content-Disposition: form-data; name="imgFile[]"; filename="Table_Msg_Content.GIF"
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary
--A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU--

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Uploading multiple files via HttpClient

sebb-2-2
HttpClient has moved from Commons. See

http://hc.apache.org/mail-lists.html

for mailing lists.

(You may get an answer here, but far more people that know HttpClient
follow the new list).

On 16/03/2009, dan06 <[hidden email]> wrote:

>
>  I've put together code that can send one file at at time via HTTP. When I
>  send more than one at a time the first file is processed but then the app
>  hangs. My hunch is the problem is caused by the boundaries of the HTTP
>  parts. Can anyone tell me:
>
>  1. If my hunch is correct, and if not what the actual problem is.
>  2. How to resolve the problem.
>
>  Below is the code I'm using to create the request entity:
>
>  try{
>         for (File selectedFile : selectedFiles){
>         Part[] parts = {new FilePart("imgFile[]", selectedFile)};
>         post.setRequestEntity( new MultipartRequestEntity( parts, post.getParams()
>  ) );
>         ...
>         ...
>         }
>  } catch (Exception e) {
>
>  Following is the request entity header info:
>
>  --3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr
>  Content-Disposition: form-data; name="imgFile[]";
>  filename="Inbox_Msg_Display.GIF"
>  Content-Type: application/octet-stream; charset=ISO-8859-1
>  Content-Transfer-Encoding: binary
>  --3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr--
>
>  --A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU
>  Content-Disposition: form-data; name="imgFile[]";
>  filename="Table_Msg_Content.GIF"
>  Content-Type: application/octet-stream; charset=ISO-8859-1
>  Content-Transfer-Encoding: binary
>  --A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU--
>
>  Thanks!
>
> --
>  View this message in context: http://www.nabble.com/Uploading-multiple-files-via-HttpClient-tp22541679p22541679.html
>  Sent from the Commons - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [hidden email]
>  For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]