Send image as json entry android

后端 未结 4 965
别那么骄傲
别那么骄傲 2021-02-11 09:17

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:49

    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

提交回复
热议问题