Java 调用三方文件上传接口
- url 为三方接口地址
- files为上传的文件信息,类型为File类型
// 构造MultiResource
MultiResource multiResource = new MultiResource(files.stream().map(multipartFile -> {try {return new InputStreamResource(Files.newInputStream(multipartFile.toPath()), multipartFile.getName());} catch (IOException e) {throw new BizException(FILE_PARSE_ERROR);}}).collect(Collectors.toList()));// 调用三方接口,上传文件HttpResponse response = HttpRequest.post(url).form("file", multiResource).execute();