一、上传文件到服务端
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String UploadFile(
@ApiParam("文件上传对象") MultipartFormDataInput input){}
二、调用第三方接口上传
public String UploadFile(MultipartFormDataInput artifactInput) throws Exception {
Map<String, List<InputPart>> importForm = artifactInput.getFormDataMap();
List<InputPart> inputParts = null == importForm ? null : importForm.get("input");
if (inputParts.isEmpty()) {
throw new Exception();
}
InputPart inputPart = inputParts.get(0);
InputStream inputStream = inputPart.getBody(InputStream.class, null);
HttpClient httpClient = new HttpClient("url").method(HttpClient.PUT);
Response response = httpClient.request(inputStream, 0);
inputStream.close();
return response.getBody();
}