【发布时间】:2020-04-16 22:12:33
【问题描述】:
是否可以发送如下邮递员截图所示的文件?我知道我们可以像发送顶级对象一样发送文件。如下所示:
@Multipart
@POST("audition/register-member")
Observable<ResponseObject<String>> sendAuditionData(@Part("name") RequestBody name,
@Part("contact") RequestBody contact,
@NotNull @Part("district") RequestBody district,
@Part("estdDate") RequestBody estdDate,
@Part("reason") RequestBody reason,
@Part("type") RequestBody type,
@Part("link") RequestBody link,
@Part MultipartBody.Part video,
@Part MultipartBody.Part image
);
// eg: of creating body
val name = RequestBody.create("multipart/form-data".toMediaType(), fullName)
val imageBody = MultipartBody.Part.createFormData("image", selectedFile?.getName(), fileBody); // fileBody is (ProgressRequestBody impl RequestBody)
但是我们如何发送带有文件的成员数组对象,如下面的邮递员所示。
【问题讨论】: