Send image as json entry android

后端 未结 4 2213
伪装坚强ぢ
伪装坚强ぢ 2021-02-11 08:59

I have a requirement where, i am sending a json file to the server and the parsing happens at the server side. I have created the entries to the json file, now i want to store a

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-11 09:29

    If you want to include Image in a JSON object which you will be sending in a request, convert Image into Base64 string and put this string into the JSON object.

    For example:

    String encodedImage = Base64.encodeToString(byteArrayImage, Base64.DEFAULT);
    

    Check:

    • How to convert a image into Base64 string?
    • Convert png or jpg image to Base64 string in Android

提交回复
热议问题