【发布时间】:2016-04-01 21:25:12
【问题描述】:
我正在使用 retrofit2+rxAndroid 来处理 REST。我想发送带有图像和文本的多部分请求。但是有些东西不起作用,而不是图像+文本,我有这个“trim,nshtml,max|140”。
这是我的要求:
@Multipart
@POST("feed/post/add")
public Observable<VehicleSearchResponse>
addPost(@Header("Authorization") String token, @Header("Content-Type") String contenttype,
@Part("text") String message,
@Part("attached_images") RequestBody file);
这就是我形成我的 RequestBody 的方式
RequestBody.create(MediaType.parse("image/jpg"), persistImage(bitmap2, "test"))
请帮帮我。
【问题讨论】:
-
我将请求更改为@Multipart @POST("feed/post/add") public Observable
addPost(@Header("Authorization") String token, @Part("attached_images\" ; filename=\"image.jpg\" ") RequestBody file,@Part("text") String test ); 但现在我的文本部分看起来像 "text"