use of org.eclipse.sw360.commonIO.AttachmentFrontendUtils in project sw360portal by sw360.
the class Sw360AttachmentService method uploadAttachment.
public Attachment uploadAttachment(MultipartFile file, Attachment newAttachment, User sw360User) throws IOException, TException {
// TODO: shouldn't the fileName be taken from newAttachment?
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
final AttachmentContent attachmentContent = makeAttachmentContent(fileName, contentType);
final AttachmentConnector attachmentConnector = getConnector();
Attachment attachment = new AttachmentFrontendUtils().uploadAttachmentContent(attachmentContent, file.getInputStream(), sw360User);
attachment.setSha1(attachmentConnector.getSha1FromAttachmentContentId(attachmentContent.getId()));
AttachmentType attachmentType = newAttachment.getAttachmentType();
if (attachmentType != null) {
attachment.setAttachmentType(attachmentType);
}
CheckStatus checkStatus = newAttachment.getCheckStatus();
if (checkStatus != null) {
attachment.setCheckStatus(checkStatus);
}
return attachment;
}
Aggregations