Android 使用改型2@Multipart将图像文件和json发送到服务器
我有一个包含许多字符串的大JSON和一个图像文件。 为了生成请求 这是imageFilePartAndroid 使用改型2@Multipart将图像文件和json发送到服务器,android,retrofit2,Android,Retrofit2,我有一个包含许多字符串的大JSON和一个图像文件。 为了生成请求 这是imageFilePart MultipartBody.Part filePart = MultipartBody.Part.createFormData("file", file.getName(), RequestBody.create(MediaType.parse("image/*"), file)); 我应该为尸体请求做什么? 这是我的界面 @POST("/api/v1.0/....") @Multipart C
MultipartBody.Part filePart = MultipartBody.Part.createFormData("file",
file.getName(), RequestBody.create(MediaType.parse("image/*"), file));
我应该为尸体请求做什么?
这是我的界面
@POST("/api/v1.0/....")
@Multipart
Call<ResponseBody> post(@Part("json_part") RequestBody
company_name, @Part MultipartBody.Part imagefile);
@POST(“/api/v1.0/…”)
@多部分
Call post(@Part(“json_Part”)请求主体
公司名称,@Part MultipartBody.Part imagefile);
到目前为止,我有(@Body MyRequest request)
,但现在我无法在执行多部分时使用它。
我需要一种将MyRequest转换为RequestBody的方法MyRequest是一个包含许多字符串成员的文件