hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ANEESHCH <aneesh.c...@gmail.com>
Subject Re: Max file size which can be transmitted using HttPClient
Date Sun, 21 Sep 2008 21:11:48 GMT

I tried the following options so far.
1) Based on the unbuffered post, used 
httppost.setRequestEntity(new InputStreamRequestEntity(
        new FileInputStream(file), file.length()));

It gave me the error, org.apache.commons.httpclient.ProtocolException:
Unbuffered entity enclosing request can not be repeated. in the system error

2) Then I tried using FileRequestEntity, to make sure that content can be
recreated, as well as for marking the entity as repeatable
No error was reported any where, but the file was not uploaded to the remote
Httpstatus code 404 was returned by the excecutemethod();

But initially, when I didn't set any value for the contenttype, it gave me
an IO Exception, read error, then I set the content type as "tex/plain;
UTF-8", the IO Error went away.

Please share your thoughts on this, some how I want to make this work.

<code snippet>
public void write(InputStream inStream, String url, int port, String user,
			String password, String host) {

		PostMethod httppost = null;

		try {
			System.out.println("Inside File Streamer: url=" + url + "; port="
					+ port + "; user=" + user + ";password=" + password);

			httppost = new PostMethod(url);
			File file = new File("F:\\FileServers.txt");
			httppost.setRequestEntity(new FileRequestEntity(file));
			HttpClient client = new HttpClient();
					new AuthScope(host, port,
					new UsernamePasswordCredentials(user, password));
			int status = client.executeMethod(httppost);
			if (status == HttpStatus.SC_OK) {
					+ httppost.getResponseBodyAsString());
			} else {
				System.out.println("Unexpected failure: " +
		} finally {
			if (httppost != null) {


</code snippet>

> Hi,
> I have a requirement for sending a huge stream, created by uploading a 2GB
> file, using fileupload to a remote file share using Http. When I'm tried
> with java.net.HttpURLConnection, it was failing by throwing OutOfmemory
> error. 
> 1) Can I make use of HttpClient in this scenario? 
> 2)What's the max file size which can be send using HttpClient?
> 3)Is it request streaming which I have to use for this purpose.
> My application is running on, Websphere Application Server ND 5.1. and the
> current max heap size of eah JVM is 768M.
> Any help is appreciated..
> Thanks in advance
> -A

View this message in context: http://www.nabble.com/Max-file-size-which-can-be-transmitted-using-HttPClient-tp19585600p19598508.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message