Returning a blob with json

后端 未结 3 714
温柔的废话
温柔的废话 2020-12-06 05:22

I\'m trying to create a rest service for my android application where an external database returns items to be stored in the applications local database. I\'ve got everythi

3条回答
  •  长情又很酷
    2020-12-06 06:06

    Encode the binary data as base64 before you generate the JSON.

    $obj->picture = base64_encode($binaryData);
    

    You can then decode this in your Android application with any base 64 decoder. Since API level 8 there is a built in util class. Otherwise there are plenty of external libs you can use for targetting Android 2.1 or earlier.

提交回复
热议问题