use of org.finos.symphony.toolkit.workflow.response.AttachmentResponse in project spring-bot by finos.
the class JerseyAttachmentHandlerConfig method attachmentHandler.
@Bean
public AttachmentHandler attachmentHandler() {
return new AttachmentHandler() {
@Override
public Object formatAttachment(AttachmentResponse ar) {
File temp;
try {
temp = File.createTempFile(ar.getName(), "." + ar.getExtension());
FileOutputStream fos = new FileOutputStream(temp);
fos.write(ar.getAttachment());
fos.close();
} catch (Exception e) {
throw new RuntimeException("Couldn't create file", e);
}
FileDataBodyPart fdbp = new FileDataBodyPart("attachment", temp);
return fdbp;
}
};
}
Aggregations