On May 30, 2012, at 3:48 PM, Mark wrote:
>                bytesAvailable = fileInputStream.available();
>                bufferSize = Math.min(bytesAvailable, maxBufferSize);
>                buffer = new byte[bufferSize];
> 
>                // Read file
>                bytesRead = fileInputStream.read(buffer, 0, bufferSize);
> 
>                while (bytesRead > 0)
>                {
>                outputStream.write(buffer, 0, bufferSize);
>                bytesAvailable = fileInputStream.available();
>                bufferSize = Math.min(bytesAvailable, maxBufferSize);
>                bytesRead = fileInputStream.read(buffer, 0, bufferSize);
>                }

How about changing this code into;

// choose suitable constant size.
byte[] buffer = new byte[8192];
int bytesRead;
while((bytesRead = fileInputStream.read(buffer) != -1) {
        outputStream.write(buffer, 0, bytesRead);
}

Also switching to chunked transfer mode might help, otherwise you should 
calculate whole HTTP POST request size into header. And I'm guessing it should 
be done by hand and is not automatically calculated by HttpURLConnection.

--
H

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to