Retrofit for android @Multipart remove default headers

倾然丶 夕夏残阳落幕 提交于 2019-12-05 10:50:46

You can build multipart body by your self in this way (kotlin code but same idea may be expressed with java):

val mpart = MultipartBody.Builder()
            .addFormDataPart("param", paramValue)
            .addPart(null, someRequestBody).build() // <-- (*) see explanation below

//thus, service method should looks like this:
@POST("upload/endpoint")
fun upload(@Body parts: MultipartBody)

(*) - this is the addPart(headers: Headers, reqBody: RequestBody) method, when you pass null to headers arg this removes all headers except Content-Length:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!