Class CmsInputStreamDataSource
- All Implemented Interfaces:
javax.activation.DataSource
InputStream
.
It's intended use is for creation of mail attachments from strings without having to create RFS
or VFS resources. Note that this data source will only support read operations and operations
related to writing will throw an UnsupportedOperationException
.
- Since:
- 6.1.7
-
Constructor Summary
ConstructorDescriptionCmsInputStreamDataSource
(InputStream in, String contentType, String name) Constructor with mandatory input stream, content type and name. -
Method Summary
Modifier and TypeMethodDescriptionRetunrs the underlying input stream of this data source.getName()
Don't use this method, VFS resources can't be written using this datasource class.
-
Constructor Details
-
CmsInputStreamDataSource
Constructor with mandatory input stream, content type and name.Note that the given input stream has to be resettable. During a mail creation and transmission cycle it is potentially read twice (commons-email-1.0.jar in combination with activation.jar) and the 2nd time the actual transport to the serial data to transmit is done. So a reset will be made here whenever the internal input stream is retrieved to avoid that the attachments remain empty.
The contentType argument should always be a valid MIME type. It is suggested that it is "application/octet-stream" if the DataSource implementation can not determine the data type. For textual data it should be "text/<subtype>; charset=<encoding>" to give a hint about the ecoding. Note that some textual documents like xml have their own encoding directive contained and the charset given here (for the mail part header) should not be different from the contained one.
- Parameters:
in
- the underlying source of data.contentType
- the correct MIME type of the data along with the charset in the form of a string (see comment above).name
- the name that describes the data in the underyling input stream. E.g. the name of a file that the input stream reads from.
-
-
Method Details
-
getContentType
- Specified by:
getContentType
in interfacejavax.activation.DataSource
- See Also:
-
DataSource.getContentType()
-
getInputStream
Retunrs the underlying input stream of this data source.- Specified by:
getInputStream
in interfacejavax.activation.DataSource
- Returns:
- the underlying input stream of this data source.
- Throws:
IOException
- if the constructor-given input stream is not "resettable" (InputStream.reset()
).- See Also:
-
DataSource.getInputStream()
-
getName
- Specified by:
getName
in interfacejavax.activation.DataSource
- See Also:
-
DataSource.getName()
-
getOutputStream
Don't use this method, VFS resources can't be written using this datasource class.This method will just return a new
.ByteArrayOutputStream
- Specified by:
getOutputStream
in interfacejavax.activation.DataSource
- See Also:
-
DataSource.getOutputStream()
-