改造2张贴图片和其他数据

时间:2017-03-23 04:58:28

标签: android retrofit2

大家好我想通过Retrofit2发布图片和其他数据请指导我缺少我的代码

Map<Integer, Set<String>> collect7 = new HashMap<>();

for(Person p: persons) {
    Set<String> hobbies = collect7.getOrDefault(p.age, new HashSet<>());
    hobbies.addAll(p.hobbies);
    collect7.put(p.age, hobbies);
}

php部分

@Multipart
    @POST(HttpConstants.FILEUPLOADJSON1)
    Call<Result>uploadImage(@Part MultipartBody.Part file,@Query("stdID")int stdID);

1 个答案:

答案 0 :(得分:0)

在Multipart请求中使用@Part代替@Query

在您的Retrofit api界面中,将您的参数传递给followws。

 @Multipart
        @POST(HttpConstants.FILEUPLOADJSON1)
        Call<Result>uploadImage(@Part MultipartBody.Part file, @Part("stdID") stdID);

我希望它为你工作