Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add InputStreamEmailAttachment
- Loading branch information
Showing
7 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
core/impl/src/main/java/org/jboss/seam/mail/core/InputStreamEmailAttachment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.jboss.seam.mail.core; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.jboss.seam.mail.core.enumurations.ContentDisposition; | ||
|
||
import com.google.common.io.ByteStreams; | ||
|
||
/** | ||
* | ||
* @author Cody Lerum | ||
* | ||
*/ | ||
public class InputStreamEmailAttachment extends BaseEmailAttachment | ||
{ | ||
public InputStreamEmailAttachment(InputStream inputStream, String fileName, String mimeType, ContentDisposition contentDisposition) | ||
{ | ||
super(); | ||
|
||
try | ||
{ | ||
super.setFileName(fileName); | ||
super.setMimeType(mimeType); | ||
super.setContentDisposition(contentDisposition); | ||
super.setBytes(ByteStreams.toByteArray(inputStream)); | ||
} | ||
catch (IOException e) | ||
{ | ||
throw new AttachmentException("Wasn't able to create email attachment from InputStream"); | ||
} | ||
} | ||
|
||
public InputStreamEmailAttachment(InputStream inputStream, String fileName, String mimeType, ContentDisposition contentDisposition, String contentClass) | ||
{ | ||
this(inputStream, fileName, mimeType, contentDisposition); | ||
super.addHeader(new Header("Content-Class", contentClass)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters