use of org.glassfish.jersey.media.multipart.file.FileDataBodyPart in project camel by apache.
the class BonitaAPIUtil method uploadFile.
public UploadFileResponse uploadFile(ProcessDefinitionResponse processDefinition, FileInput file) throws Exception {
WebTarget resource = webTarget.path("portal/resource/process/{processName}/{processVersion}/API/formFileUpload").resolveTemplate("processName", processDefinition.getName()).resolveTemplate("processVersion", processDefinition.getVersion());
File tempFile = File.createTempFile("tempFile", ".tmp");
FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(file.getContent());
fos.close();
final FileDataBodyPart filePart = new FileDataBodyPart("file", tempFile, MediaType.APPLICATION_OCTET_STREAM_TYPE);
final MultiPart multipart = new FormDataMultiPart().bodyPart(filePart);
return resource.request().accept(MediaType.APPLICATION_JSON).post(entity(multipart, MediaType.MULTIPART_FORM_DATA), UploadFileResponse.class);
}
Aggregations