如何使用改造在同一参数上添加多个图像/文件以及其他文本数据?
Single image is uploading perfectly using following interface
@Multipart
@POST("/users/updateProfile/")
public void updateProfileWithImage(
@Part("user_id") TypedString first_name,
@Part ("image") TypedFile image,
Callback<WebResponse> callback);
最佳答案
您可以使用带有@PartMap 作为参数的@MultiPart Post
Map<String, TypedFile> files = new HashMap<String, TypedFile>();
files.put("my file number one", new TypedFile("image/jpg", new File(filename)));
files.put("my file number two", new TypedFile("image/jpg", new File(filename)));
apiInterface.updateProfileWithImage("first name here", files);
private interface ApiInterface{
@Multipart
@POST("/users/updateProfile/")
Response updateProfileWithImage(
@Part("user_id") TypedString first_name,
@PartMap Map<String,TypedFile> Files
);
}
关于android - 在使用改造发布多个图像文件方面需要帮助吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22658797/