Hi,
I have a need of uploading a file using Apache HttpClient whose size > 2GB.
'm using Weblogic 10.3 as my server.
I have written the following code to upload files using HttpClient 4.3.4.
This code works fine for all files < 2 GB.
For files > 2GB, I get the following error on my client:
INFO: I/O exception (java.net.SocketException) caught when processing
request to {}->http://<client_ip>: Connection reset by peer: socket write
error
18 Jul, 2014 9:00:07 PM org.apache.http.impl.client.DefaultHttpClient
tryExecute
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at
org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:181)
at
org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
at
org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:120)
and on the server I get the following error:
<ExecuteThread: '0' for queue: 'weblogic.socket.Muxer'> <<WLS Kernel>> <>
<> <1405696485817> <BEA-101215> <Malformed Request
"⃔�X��)���HY�#����`�49�O��VrI9�����r�]Ie���r�". Request parsing
failed, Code: -1>
Is there a way to upload files > 2 GB?
Code:
--------
File file = new File(<file_name>);
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_1);
HttpPost post = new HttpPost(url);
MultipartEntity entity = new MultipartEntity(
HttpMultipartMode.STRICT);
// For File parameters
entity.addPart( "application", new FileBody((( File ) file ) ));
System.out.println("Uploading file...");
post.setEntity( entity );
String response = EntityUtils.toString( client.execute( post
).getEntity(), "UTF-8" );
client.getConnectionManager().shutdown();
Regards,
Ashish