/** * 多文件上传 方法一 * @param description * @param imgs1 * @param imgs2 * @return */ @POST("upload/uploadFile.do") Observable<BasicResponse> uploadFiles(@Part("filename") String description, @Part("pic\"; filename=\"image1.png") RequestBody imgs1, @Part("pic\"; filename=\"image2.png") RequestBody imgs2);
@Multipart @POST("/v2/photomap.add") Call<UploadPhotoResponseDto> uploadPhoto(@Part("username") RequestBody username, @Part("password") RequestBody password, @Part("longitude") double lon, @Part("latitude") double lat, @Part("datetime") long dateTime, @Part("category") RequestBody category, @Part("metacategory") RequestBody metaCat, @Part("caption") RequestBody caption, @Part MultipartBody.Part file); }
/** * For sending file in multipart call MultiPartUtil.getMultipartFile(File file); * for sending string in RequestBody call MultiPartUtil.getMultipartString(String string) * for uploading files with other parameters * * @param someInteger random integer * @param someString random String * @param file random file */ @POST("update-profile") Observable<ContactInfoModel> multipart( @Part("someInteger") int someInteger, @Part("someString") RequestBody someString, @Part MultipartBody.Part file);
/** * {@link Part} 后面支持三种类型,{@link RequestBody}、{@link okhttp3.MultipartBody.Part} 、任意类型 * 除 {@link okhttp3.MultipartBody.Part} 以外,其它类型都必须带上表单字段({@link okhttp3.MultipartBody.Part} 中已经包含了表单字段的信息), */ @POST("/form") @Multipart Call<ResponseBody> testFileUpload1(@Part("name") RequestBody name, @Part("age") RequestBody age, @Part MultipartBody.Part file);
/** * Create a manifest * Create firmware manifest. * @param datafile The manifest file to create. The API gateway enforces the account-specific file size. (required) * @param name The name of the firmware manifest (required) * @param description The description of the firmware manifest (optional) * @param keyTable The key table of pre-shared keys for devices (optional) * @return Call<FirmwareManifest> */ @retrofit2.http.Multipart @POST("v3/firmware-manifests/") Call<FirmwareManifest> firmwareManifestCreate( @retrofit2.http.Part() MultipartBody.Part datafile, @retrofit2.http.Part("name") String name, @retrofit2.http.Part("description") String description, @retrofit2.http.Part() MultipartBody.Part keyTable );
/** * Create an image * Create firmware image. * @param datafile The firmware image file to upload (required) * @param name The name of the firmware image (required) * @param description The description of the firmware image (optional) * @return Call<FirmwareImage> */ @retrofit2.http.Multipart @POST("v3/firmware-images/") Call<FirmwareImage> firmwareImageCreate( @retrofit2.http.Part() MultipartBody.Part datafile, @retrofit2.http.Part("name") String name, @retrofit2.http.Part("description") String description );
/** * @param entityType - Type for which document is being uploaded (Client, Loan * or Savings etc) * @param entityId - Id of Entity * @param nameOfDocument - Document Name * @param description - Mandatory - Document Description * @param typedFile - Mandatory */ @POST("{entityType}/{entityId}/" + ApiEndPoints.DOCUMENTS) @Multipart Observable<GenericResponse> createDocument( @Path("entityType") String entityType, @Path("entityId") long entityId, @Part("name") String nameOfDocument, @Part("description") String description, @Part() MultipartBody.Part typedFile);
/** * 单文件上传 * @param file * @return */ @Multipart @POST("chatfiles") Call<ResponseBody> upload(@Part MultipartBody.Part file);