Hi Carmen,
I run into the same OutOfMemoryError issue when uploading video files of
several MB within my app. I decided to look into this for the next version
of the app. So, in the unlikely event you still haven't found a solution
for this, here is how I get an answer from the server, even when using
setChunkedStreamingMode:
DataInputStream inStream = new DataInputStream ( conn.getInputStream() );
String oneLine, fullMsg="", msgStr;
while (( oneLine = inStream.readLine()) != null) {
if (DEBUG) Log.d(TAG, "Server Response: " + oneLine);
fullMsg += oneLine + "\n";
}
inStream.close();
I could have used a StringBuilder for fullMsg, but I have 2 lines at most
coming from the server.
Robert
------
http://dailyroads.com/voyager/
If I upload a large file using an HttpURLConnection and
setChunkedStreamingMode the file is successfully uploaded. But, I am not
able to read the response from the server.
If I leave out streaming mode line:
conn.setChunkedStreamingMode(1000*1024);
I get an out of memory error on large file, but this works well for small
files and I get a response from the server.
Any insights on this?
Carmen
// Set up URL Connection for streaming
HttpURLConnection conn = (HttpURLConnection) connectURL.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setChunkedStreamingMode(1000*1024);
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Type",
"multipart/form-data;boundary="+boundary);
// Read response
// this works for small files when not in streaming mode
// for large files, connection is reset by server (time outs)
Reader reader = new InputStreamReader( conn.getInputStream() );
StringBuilder in = new StringBuilder( 32000 );
int x;
while ( (x=reader.read()) != -1 ){
in.append( (char)x );
}
--
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