Android HttpClient not sending more than 10 MB outofmemory issue
₹600-1000 INR
処理中
投稿日: 7年以上前
₹600-1000 INR
完了時にお支払い
We were unable to send more than 10MB file to HttpServer .below is the code for sending the file. we need to send 100MB file to server.
public int Sending() throws IOException {
String iFileName = "[login to view URL]";
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
String Tag = "fSnd";
try {
Log.e(Tag, "Starting Http File Sending to URL");
// Open a HTTP connection to the URL
conn = (HttpURLConnection) [login to view URL]();
// Allow Inputs
[login to view URL](true);
// Allow Outputs
[login to view URL](true);
// Don't use a cached copy.
[login to view URL](false);
//[login to view URL](5120);
// Use a post method.
[login to view URL]("POST");
[login to view URL]("Connection", "Keep-Alive");
[login to view URL]("Content-Type", "multipart/form-data;boundary=" + boundary);
DataOutputStream dos = new DataOutputStream([login to view URL]());
[login to view URL](twoHyphens + boundary + lineEnd);
[login to view URL]("Content-Disposition: form-data; name=\"title\"" + lineEnd);
[login to view URL](lineEnd);
[login to view URL](Title);
[login to view URL](lineEnd);
[login to view URL](twoHyphens + boundary + lineEnd);
[login to view URL]("Content-Disposition: form-data; name=\"description\"" + lineEnd);
[login to view URL](lineEnd);
[login to view URL](Description);
[login to view URL](lineEnd);
[login to view URL](twoHyphens + boundary + lineEnd);
[login to view URL]("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + iFileName + "\"" + lineEnd);
[login to view URL](lineEnd);
Log.e(Tag, "Headers are written");
// create a buffer of maximum size
int bytesAvailable = [login to view URL]();
int maxBufferSize = 5120;
int bufferSize = [login to view URL](bytesAvailable, maxBufferSize);
byte[] buffer = new byte[bufferSize];
// read file and write it into form...
int bytesRead = [login to view URL](buffer, 0, bufferSize);
// [login to view URL]([login to view URL]().size());
while (bytesRead > 0) {
[login to view URL](buffer, 0, bufferSize);
bytesAvailable = [login to view URL]();
bufferSize = [login to view URL](bytesAvailable, maxBufferSize);
bytesRead = [login to view URL](buffer, 0, bufferSize);
}
// while (bytesRead > 0){
// bufferSize = [login to view URL](bytesAvailable, maxBufferSize);
// byte byt[]=new byte[bufferSize];
// [login to view URL](byt);
// bytesRead = [login to view URL](buffer, 0, bufferSize);
// [login to view URL](buffer, 0, bufferSize);
// }
[login to view URL](lineEnd);
[login to view URL](twoHyphens + boundary + twoHyphens + lineEnd);
// close streams
[login to view URL]();
[login to view URL]();
Log.e(Tag, "File Sent, Response: " + [login to view URL]([login to view URL]()));
// InputStream is = [login to view URL]();
// retrieve the response from server
int ch;
// StringBuffer b =new StringBuffer();
// while( ( ch = [login to view URL]() ) != -1 ){ [login to view URL]( (char)ch ); }
// String s=[login to view URL]();
// Log.i("Response",s);
[login to view URL]();
} catch (MalformedURLException ex) {
Log.e(Tag, "URL error: " + [login to view URL](), ex);
return 0;
} catch (IOException ioe) {
Log.e(Tag, "IO error: " + [login to view URL](), ioe);
return 0;
}
return [login to view URL]();
}
I have been developing android programs for 4 years.
I have developed many apks.
So I think I can do it so that you satisfy.
I am looking forward to being hired by you.
I'll do my best to do it.
Please award my bid and hire me.
I'll make you satisfy.
Believe me.
And Contact to me.
I can start my work at once.
I'll wait your visit.
Thank you!