1
我用来发送POST请求与改造1.9:多部分改造1.9 - > 2
TypedFile typedFile = picture != null ? new TypedFile("image/*", tempFile) : null;
@Multipart
@POST("/goals")
Observable<Goal> postGoal(
@Part("name") String name,
@Part("picture") TypedFile picture
);
我搬到改造2.0.2,但我不能让它的工作是相同的。据https://github.com/square/retrofit/issues/1140我用:
RequestBody name = RequestBody.create(MediaType.parse("text/plain"), name);
RequestBody picture = RequestBody.create(MediaType.parse("image/*"), tempFile);
@Multipart
@POST("goals")
Observable<Goal> postGoal(
@Part("name") RequestBody name,
@Part("picture\"; filename=\"temp.png\" ") RequestBody picture
);
但似乎没有请求的文件(照片)是怎么回事。哪里不对 ?
是的,这正是我所发现的为好。我希望尽管会有更清晰的解决方案;)Thx! –