List of usage examples for javax.mail.util ByteArrayDataSource getContentType
@Override
public String getContentType()
From source file:stg.pr.engine.mailer.SmallEmailAttachment.java
/** * Constructs the SamllEmailAttachment using the given name and the {@link ByteArrayDataSource} * @param name The name of the attachment. * @param datasource The data source is fully read and stored in bytes array provided the length of the bytes is < {@link EMailAttachment#SMALL_SIZE}. *///from w w w . jav a 2 s . com public SmallEmailAttachment(String name, ByteArrayDataSource datasource) throws IOException { super(name, datasource); if (datasource.getInputStream().available() > EMailAttachment.SMALL_SIZE.longValue()) { throw new IllegalArgumentException("Small email attachments are for file size < 1MB"); } contentType = datasource.getContentType(); this.bytes = IOUtils.toByteArray(datasource.getInputStream()); }