Android - Upload Large image to server -


i trying have application upload images webserver using code below. works sometimes, seems fail memory error. can please post example of how accomplish if file size big? also, building support 1.5 , up. don't mind if code given me resizes image smaller before upload.

httpclient httpclient = new defaulthttpclient();  httppost httppost = new httppost(urlstring);  file file = new file(nameoffile);  fileinputstream fileinputstream = new fileinputstream(file); inputstreamentity reqentity = new inputstreamentity(fileinputstream, file.length());  httppost.setentity(reqentity); reqentity.setcontenttype("binary/octet-stream"); httpresponse response = httpclient.execute(httppost); httpentity responseentity = response.getentity();  if (responseentity != null) {     responseentity.consumecontent(); }  httpclient.getconnectionmanager().shutdown(); 

you have 2 option make code workable.

  1. you should use multi part approach upload larger size file. using in code. its apache code. (yes, can port in android project).

  2. you can minimize image resolution. using samplesize flag, follow this link.

i hope help.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -