Я использую Retrofit beta2, и я борюсь за многостраничную загрузку. Я пробовал код, как указано here. Возможно, я что-то пропустил.Retrofit 2 beta2 не удалось выполнить многостраничную загрузку
public interface SendMediaApiService {
@Multipart
@POST(/api/v1/messages)
Call<ApiResponse> upload(
@Header("Authorization") String token,
@Query("recipient_user_id") String userId,
@Query("message") String message,
@Part("name=\"photo\"; filename=\"selfie.jpg\" ") RequestBody file
);
}
private void upload() {
Retrofit retrofit = new Retrofit.Builder()
// do some stuffs here
File file = new File(filePath);
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
Call<ApiResponse> call = service.upload(token, userId, msg, requestBody);
}
когда я свернуться
$ curl -v \
> -H "Authorization: Bearer TOKEN" \
> -F "[email protected]/path/to/my/image.jpg" \
> http://domain.com/api/v1/messages?recipient_user_id=USER_ID&message=test
вы правы @peitek, вы просто должны удалить 'имя = \" 'часть – chip