[ 
https://issues.apache.org/jira/browse/EMAIL-204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17684626#comment-17684626
 ] 

HiuFung commented on EMAIL-204:
-------------------------------

Hi [~ggregory], I have created MR for this, would that be possible for you have 
a look?

[https://github.com/apache/commons-email/pull/135]

 

Thanks,

 

> Parsing multipart should not load content in to memory
> ------------------------------------------------------
>
>                 Key: EMAIL-204
>                 URL: https://issues.apache.org/jira/browse/EMAIL-204
>             Project: Commons Email
>          Issue Type: Improvement
>            Reporter: Deryl Spielman
>            Priority: Major
>
> When parsing a MimeMessage and the message has attachments it is eagerly 
> loading the content in to a memory via byteArray to create a DataSource. This 
> is inefficient when all I need is a list of attachments which can be pulled 
> from the content disposition for file name.
> If the attachments are large these lines load it in to memory when perhaps it 
> should keep it as an input stream so as not to force loading in to memory 
> until it's actually used by somewhere else in the code.
> *MimeMessageParser.java*
> {code:java}
>     protected DataSource createDataSource(final Multipart parent, final 
> MimePart part)
>         throws MessagingException, IOException
>     {
>         final DataHandler dataHandler = part.getDataHandler();
>         final DataSource dataSource = dataHandler.getDataSource();
>         final String contentType = 
> getBaseMimeType(dataSource.getContentType());
> ---->final byte[] content = this.getContent(dataSource.getInputStream());
> ---->final ByteArrayDataSource result = new ByteArrayDataSource(content, 
> contentType);
>         final String dataSourceName = getDataSourceName(part, dataSource);
>         result.setName(dataSourceName);
>         return result;
>     }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to