Android Multipart HTTP Post does not send the File's MIME type

后端 未结 6 1155
挽巷
挽巷 2021-02-05 21:53

Trying to figure what\'s wrong with my codings. I followed a blog post from here.

I managed to get the codes to actually upload the file to a PHP web service. However, f

6条回答
  •  囚心锁ツ
    2021-02-05 21:53

    So while all the above answers did help in getting it right.

    But just removing the HttpMultipartMode.BROWSER_COMPATIBLE wouldn't solve it.

    You can set the mime type by doing this

    ByteArrayBody bab = new ByteArrayBody(params.getByteArray("data"), "image/jpeg" , "image.jpg");
    

    N.B. I am using the latest repackaged android client http://code.google.com/p/httpclientandroidlib/ which supports multipart uploads, etc.

提交回复
热议问题