java - How to attach large files (stored online) to an email without copying the entire file to memory -
How do I send an email using the Java Mail API, which has large attachments (~ 25 MB)? Attachments are stored files online with our Cloud Storage Provider (Google Cloud Storage) The API provides an InputStream object or a Reidblabel channel object for each file for the service.
I can not use BioArchivedata to create the MaitiBodaPart because it creates a copy of the entire file that stays in memory, and we get an out-of-memory exception
< P> If it has a physical file, then we can create a file data source object and attach the email. But what can we do with the inputstream object?I can not increase the size of the heap because it is growing up to 25 MB seems like a very bad idea. If you have any other ideas, please let me know on the Google App Engine platform. Are working.
Try instead or otherwise, otherwise you should return your given input stream directly to your own Can create adapter class.
Public class InputStreamDataSource implements javax.activation.DataSource {Private Final InputStream in; Public InputStreamDataSource (Last InputStream Inn) {If (== in the blank) {New NullPointerException (); } This.in = in; } @ Override Public Input Stream Received InStopStream () throws IOException {Return; } @ Override Public OutputStream throws GetOutputStream () IOException (new IOEceptionception); } @ Override public string getContentType () {Return to "Application / Octet-Stream"; } @ Override public string getName () {"name back"; }}
Comments
Post a Comment