Android sending image to Server via MultipartEntity - setting Content-type?

后端 未结 5 684
北恋
北恋 2020-12-17 22:18

I\'ve read many many posts about sending an image to the server from an Android app and Content-type-wise, they are divided in three categories:

a) they dont set the

5条回答
  •  醉梦人生
    2020-12-17 22:55

    Read the source of the file http. Check this solution:

    1. Call new MultipartEntity:

      MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName("UTF-8"));

    2. Add request header

      heads.put("Content-Type", "image/png;charset=utf-8");

提交回复
热议问题