>() {
+ });
+ }
+
+ /**
+ * 上传文件
+ *
+ * 如果isCover为空或者为false,源文件目录下存在相同文件则会报错
+ *
+ *
+ * @param username 用户名
+ * @param is 文件流
+ * @param fileName 文件名称
+ * @param uploadPath 上传路径
+ * @param isCover 是否覆盖(非必填,默认:false)
+ */
+ public void uploadFile(String username, InputStream is, String fileName, String uploadPath, Boolean isCover) {
+ if (is == null) {
+ throw new ArgsException("is是必填参数");
+ }
+ if (StringUtils.isBlank(uploadPath)) {
+ throw new ArgsException("uploadPath是必填参数");
+ }
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.setCharset(StandardCharsets.UTF_8);
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+ builder.addBinaryBody("file", is, ContentType.MULTIPART_FORM_DATA, fileName);
+ if (isCover != null) {
+ builder.addTextBody("isCover", isCover.toString());
+ }
+ builder.addTextBody("uploadPath", uploadPath);
+ HttpPost httpPost = new HttpPost(jhApiClient.getUrl(FilePathConstant.FILE_UPLOAD_PATH));
+ httpPost.setEntity(builder.build());
+ ResponseResult