Example usage for javax.mail.util ByteArrayDataSource getContentType

List of usage examples for javax.mail.util ByteArrayDataSource getContentType

Introduction

In this page you can find the example usage for javax.mail.util ByteArrayDataSource getContentType.

Prototype

@Override
public String getContentType() 

Source Link

Document

Get the MIME content type of the data.

Usage

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());
}