php - Recover base64 image from a web service in Android -


i'm developing app in android connects web service in php. users can send pictures, or better said, able send pictures cause i'm stuck on it, other users.

right image sent web service via soap type xsd:base64binary. user take picture , byte array data converted base64 before sending in way:

string img; .... @override public void onpicturetaken(byte[] data, camera camera) {      img = base64.encodetostring(data, base64.no_wrap);          } 

in server side, php stores img string in mysql blob column.

when user ask picture, server retrieves data mysql in stdclass, not image, id, owner, etc... , encapsulate data json string php function json_encode. return type in wsdl file xsd:string. in android is:

jsonarray array = new jsonarray(response); jsonobject row; string imgstr; byte[] img;  (int = 0; < array.length(); i++) {     row = array.getjsonobject(i);     ...     imgstr = row.getstring("image");     ... }  if (!textutils.isempty(imgstr)) {     img = base64.decode(imgstr, base64.no_wrap); }  //insert byte[] in android sqlite dao.insert(id, owner, img); 

the table column type in sqlite blob well. problem comes when image sqlite , try convert bitmap object. code this:

... byte[] img = cursor.getblob(cursor.getcolumnindex(db.m_img)); bitmap bmp = bitmapfactory.decodebytearray(img, 0, img.length); ... 

the img byte array seems alright bmp null...

some tests i've done getting base64 string on image owner device before sending , passing bitmap results, that's why think problem has encoding or addition of characters json or php, don't know...

update: if hardcoded base64 string mysql database, no bitmap created, if same base64 string generated in moment take picture works.

what doing wrong?

after couple of days problem, have answer, mysql issue.

apparently mysql blob type can store 64kb (a clue find bug images take same space of 64 kb...the aswer there along couldn't see it...). solution, in case, has been changing blob type in mysql longblob...

thank time.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -