public static AttachmentBuilder attachment(File file) { AttachmentBuilder builder = new AttachmentBuilder(); builder.fileName = file.getName(); FileDataSource fileDataSource = new FileDataSource(file); builder.fileContent = new DataHandler(fileDataSource); return builder; }
public static AttachmentBuilder attachment(String uri) { AttachmentBuilder builder = new AttachmentBuilder(); File fileToUpload = new File(uri); FileDataSource fileDataSource = new FileDataSource(fileToUpload); builder.fileName = fileToUpload.getName(); builder.fileContent = new DataHandler(fileDataSource); return builder; }
public static AttachmentBuilder attachment(Attachment attach) { AttachmentBuilder builder = new AttachmentBuilder(); builder.fileName = attach.getFileName(); builder.contentType = attach.getContentType(); builder.thumbnail = attach.getThumbnail(); builder.fileSize = attach.getFileSize(); return builder; }