As I mentioned in a previous posting (Subject: MultipartPostMethod Holding File Stream
Open?), I'm using the MultipartPostMethod to upload a file to a servlet. Here is the
example code that I included in the other posting:
> File file = new File(strUrl);
>
> HttpClient client = new HttpClient();
> HostConfiguration hostConfig = new HostConfiguration();
> MultipartPostMethod mpPost = new MultipartPostMethod();
>
> hostConfig.setHost(someURL.getHost(), someURL.getPort(),
> someURL.getProtocol());
> client.setConnectionTimeout(30000);
> client.setHostConfiguration(hostConfig);
>
> mpPost.addParameter("someName", "someValue");
> mpPost.addParameter(file.getName(), file);
>
> mpPost.setPath(strPath);
> client.executeMethod(mpPost);
>
> String confirmUpload = tpPost.getResponseBodyAsString();
> mpPost.releaseConnection();
I've been uploading some small text files (about 14KB each) and it seems to work
properly in this situation. However, when I try to do the same with a 20MB file (I
realize that this is a very large file, however, I want to test it's performance) a
SocketException is thrown.
java.net.SocketException: Software caused connection abort: 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:126)
at
org.apache.commons.httpclient.methods.multipart.FilePart.sendData(FilePart.java:198)
at org.apache.commons.httpclient.methods.multipart.Part.send(Part.java:197)
at
org.apache.commons.httpclient.methods.MultipartPostMethod.writeRequestBody(MultipartPostMethod.java:203)
at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1974)
at
org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2298)
at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:915)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:557)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:474)
at test.FileUploader.upload(FileUploader.java:179)
at test.FileUploader.main(FileUploader.java:341)
Is there some kind of cap on the file size that I can send? If so, at what size is
the cap set?