Android在使用Retrofit上傳文件時愈捅,前臺上傳成功显歧,后臺報錯
而postman上傳成功喇伯,抓包對比數(shù)據(jù)后發(fā)現(xiàn)俯抖,postman的頭數(shù)據(jù)里有boundary這個字段
將boundary=<calculated when request is sent>加入Android接口
上傳成功痘煤!
//上傳文件
@Multipart
@Headers("Content-Type:multipart/form-data; boundary=<calculated when request is sent>")
@POST("/admin/miniapp/api/upload/{fileType}/{id}")
Call<UpLoadSuccess> upload(@Path("fileType") String fileType, @Path("id") String id, @Part MultipartBody.Part file);