/** * Create an instance of {@link Attachment } * */ public Attachment createAttachment() { return new Attachment(); }
/** * Create an instance of {@link Attachment } * */ public Attachment createAttachment() { return new Attachment(); }
final Attachment attachment = new Attachment() .setName(isEmpty(name) ? null : name) .setType(isEmpty(type) ? null : type)
public static Attachment writeAttachment(byte[] data, String name, String passedType, Path outputDirectory) { String fileName = generateAttachmentFileName(); boolean isTypeProvided = passedType == null || passedType.isEmpty(); String type = isTypeProvided ? getAttachmentType(data) : passedType; String extension = getExtensionByMimeType(type); String source = fileName + extension; write(data, source, outputDirectory); return new Attachment().withName(name).withType(type).withSource(source); }