下面列出了怎么用retrofit2.http.Part的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public Func1<MultipartBody.Part, Observable<?>> funcUploadFile() {
return new Func1<MultipartBody.Part, Observable<?>>() {
@Override
public Observable call(MultipartBody.Part part) {
String location = mDbHelper.getActivePrinterDbEntity().getUploadLocation();
return uploadFile(location, part);
}
};
}
@Multipart
@POST("applications/{id}/upload")
Call<String[]> uploadScreenshot(
@HeaderMap final Map<String, String> httpHeaders,
@Path("id") final int applicationId,
@Query("key") final String key,
@Part("files[]\"; filename=\"screenshot.png\" ") final RequestBody filename);
@Multipart
@POST("applications/{id}/upload")
Call<String[]> uploadLogs(
@HeaderMap final Map<String, String> httpHeaders,
@Path("id") final int applicationId,
@Query("key") final String key,
@Part("files[]\"; filename=\"logs.txt\" ") final RequestBody filename);
@Multipart
@POST("/login/submit")
Call<AnimePicturesUser> login(
@Part("login") RequestBody username,
@Part("password") RequestBody password,
@Part("time_zone") RequestBody timezone
);
@Multipart
@POST
CompletableFuture<Void> uploadApp(@Url @Nonnull String url, @Part @Nonnull MultipartBody.Part file);
@Multipart
@POST("/")
Observable<Response<ResponseBody>> query(@Part MultipartBody.Part part);
@Multipart
@POST("/search.php")
Observable<Response<ResponseBody>> query(@Part MultipartBody.Part part);
@Multipart
@POST("v1/user/profile/edit")
Observable<NullResponse> updateUserProfile(@Header("Authorization") String token,
@Part List<MultipartBody.Part> parts);
@Multipart
@POST("/search")
Observable<Response<ResponseBody>> query(@Part MultipartBody.Part part);
@Multipart
@POST
Call<String> upload(@Url String url, @Part MultipartBody.Part files);
@Multipart
@POST
Observable<String> upload(@Url String url, @Part MultipartBody.Part files);
@Multipart
@POST(".")
Call<String> uploadMediaToAWS(@PartMap() Map<String, RequestBody> params, @Part() MultipartBody.Part file);
@Multipart
@POST("upload")
Call<FileUploadReponse> uploadFile(@Part MultipartBody.Part file);
@POST("add/upload-pictures")
@Multipart
//表示这个接口有文件上传
Call<ResponseBody> uploadFiles(@Part MultipartBody.Part idcardImg, @Part MultipartBody.Part bankcardImg);
@Multipart
@POST("/?s=App.CDN.UploadImg")
// @Progress()
Observable<UploadResponse> uploadImage(@Part List<MultipartBody.Part> partList);
@Multipart
@POST
Observable<ResponseBody> uploadFile(@Url String url, @QueryMap Map<String, Object> map,
@Part MultipartBody.Part image);
@Multipart
@POST
Observable<ResponseBody> uploadFileWithHeaders(@Url String url, @QueryMap Map<String, Object> map,
@Part MultipartBody.Part image, @HeaderMap Map<String, String> headers);
@Multipart
@POST
Observable<ResponseBody> uploadFile(@Url String url, @QueryMap Map<String, Object> map,
@Part() MultipartBody.Part[] images);
@Multipart
@POST
Observable<ResponseBody> uploadFileWithHeaders(@Url String url, @QueryMap Map<String, Object> map,
@Part() MultipartBody.Part[] images, @HeaderMap Map<String, String> headers);
@Multipart
@POST("api/user/modifyDevice")
Observable<BaseResponse> uploadImage(@PartMap Map<String, RequestBody> map, @Part MultipartBody.Part file);
@POST
public Observable<Response> upLoad(@Url String url, @Part MultipartBody.Part part);
@Multipart
@POST("upload")
Call<Response> uploadImage(@Query(QRY_TOKEN) String token,@Query(QRY_KID_ID) String kid_id, @Part MultipartBody.Part image);
@Multipart
@POST()
Flowable<ResponseBody> upLoadImage(
@Url() String url,
@Part("image\"; filename=\"image.jpg") RequestBody requestBody);
@Multipart
@POST()
Flowable<ResponseBody> uploadFlie(
@Url String fileUrl,
@Part("description") RequestBody description,
@Part("files") MultipartBody.Part file);
@Multipart
@POST
Flowable<ResponseBody> uploadFileWithPartMap(
@Url() String url,
@PartMap() Map<String, RequestBody> partMap,
@Part("file") MultipartBody.Part file);
@Multipart
@POST()
Observable<ResponseBody> uploadFlie(@Url String fileUrl, @Part("description") RequestBody description, @Part("files") MultipartBody.Part file);
@Multipart
@POST()
Observable<ResponseBody> uploadFiles(@Url String url, @Part() List<MultipartBody.Part> parts);
@POST("api")
@Multipart
Call<Bitmap> processPng(@Part("style") RequestBody type,
@Part("scale") RequestBody scale,
@Part("noise") RequestBody noise,
@Part("file\"; filename=\"test.png") RequestBody img);
@Multipart
@POST("/images/upload")
Call<Response> uploadImage(@Part MultipartBody.Part image);
@Multipart
@POST("{path}")
Observable<ResponseBody> uploadFile(@Path(value = "path", encoded = true) String url,
@Part("description") RequestBody description, @Part MultipartBody.Part file);