You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "yaramala (JIRA)" <ji...@apache.org> on 2009/10/20 00:30:24 UTC

[jira] Created: (EMAIL-89) email attachment size

email attachment size
---------------------

                 Key: EMAIL-89
                 URL: https://issues.apache.org/jira/browse/EMAIL-89
             Project: Commons Email
          Issue Type: Improvement
            Reporter: yaramala
            Priority: Minor


Please add  method to determine the size of attachment attached to email so that we can limit the attachments while sending via email

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (EMAIL-89) email attachment size

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12867172#action_12867172 ] 

Siegfried Goeschl commented on EMAIL-89:
----------------------------------------

Hi Kevin,

just looking the patch and would like to keep you in the loop

+) in Email#getSmtpPort you checked for MAIL_HOST before accessing MAIL_PORT

+) the MultiPartEmailTest#testAttachmentFileSize and #testAttachmentURLSize fail on Mac OS X (M2 and IntelliJ)  with >>>Cannot attach file "Users/siegfriedgoeschl/work/asf/commons/proper/email/trunk/target/test-classes/images/asf_logo_wide.gif"<<< which is entirely correct since there is no leading slash. When adding the slash the tests are passing

> email attachment size
> ---------------------
>
>                 Key: EMAIL-89
>                 URL: https://issues.apache.org/jira/browse/EMAIL-89
>             Project: Commons Email
>          Issue Type: Improvement
>            Reporter: yaramala
>            Assignee: Siegfried Goeschl
>            Priority: Minor
>         Attachments: issue-89_patch.txt
>
>
> Please add  method to determine the size of attachment attached to email so that we can limit the attachments while sending via email

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (EMAIL-89) email attachment size

Posted by "Kevin Lester (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-89?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Lester updated EMAIL-89:
------------------------------

    Attachment: issue-89_patch.txt

This patch contains the following changes:
1). New "fileSize" property added to EmailAttachment
2). New "getAttachments" method added to the MultiPartEmail class.   
3). New "removeAttachment" method added to the MultiPartEmail class.   
4). Fixed spelling mistake in BaseEmailTestCase
5). 4 new UnitTests added to test the new functionality
Note that this patch also incorporates the patch for bug 91

Summary:
This patch updates the MultiPartEmail class to now track the EmailAttachment objects that are attached to the email.  In the "attach" method, the class now fills in the EmailAttachment's "fileSize" attribute, and puts a reference to the object in a LinkedHashMap.  The key of the LinkedHashMap is set to the EmailAttachment, and the value is set to the corresponding BodyPart object.  This allows the class to now return the list of original EmailAttachment objects, as well as remove them and their corresponding BodyPart object when the "removeAttachment" method is called.  

The FileSize of an attachment is done in 1 of three ways:
1). If the attachment has its 'path' set, then the fileSize is set to the File(path).length().
2). If the attachment has its 'url' set, then the fileSize is set to the url.openConnection().getContentLenth().
3). If the 'attach' method is called with only a dataSource, then the fileSize is NOT set, and is left at the default value of -1.  This is because there doesn't appear to be a safe way to get the size without affecting the dataSource.

With this patch, users can now get the fileSize of attachments and remove them in a manner like the following:

for (Iterator iter = email.getAttachments().iterator(); iter.hasNext();){
    EmailAttachment attachment = (EmailAttachment) iter.next();
    System.out.println("Attachment size = " + attachment.getFileSize() + " bytes.");
    if (attachment.getFileSize() > MAX_SIZE){
        email.removeAttachment(attachment);
    }
}

This patch was created against the latest code in svn, and new unit tests were added to the MultiPartEmailTest.java for the new funcitonality.  All tests pass.

> email attachment size
> ---------------------
>
>                 Key: EMAIL-89
>                 URL: https://issues.apache.org/jira/browse/EMAIL-89
>             Project: Commons Email
>          Issue Type: Improvement
>            Reporter: yaramala
>            Priority: Minor
>         Attachments: issue-89_patch.txt
>
>
> Please add  method to determine the size of attachment attached to email so that we can limit the attachments while sending via email

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (EMAIL-89) email attachment size

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-89?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siegfried Goeschl closed EMAIL-89.
----------------------------------


> email attachment size
> ---------------------
>
>                 Key: EMAIL-89
>                 URL: https://issues.apache.org/jira/browse/EMAIL-89
>             Project: Commons Email
>          Issue Type: Improvement
>            Reporter: yaramala
>            Assignee: Siegfried Goeschl
>            Priority: Minor
>         Attachments: issue-89_patch.txt
>
>
> Please add  method to determine the size of attachment attached to email so that we can limit the attachments while sending via email

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (EMAIL-89) email attachment size

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-89?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siegfried Goeschl resolved EMAIL-89.
------------------------------------

    Resolution: Won't Fix

I'm highly appreciating your effort but I'm not applying the patch 

+) the application can determine the attachment size in advance and react accordingly
+) it makes the code more complex and brittle
+) it could break embedded images of HtmlEMail



> email attachment size
> ---------------------
>
>                 Key: EMAIL-89
>                 URL: https://issues.apache.org/jira/browse/EMAIL-89
>             Project: Commons Email
>          Issue Type: Improvement
>            Reporter: yaramala
>            Assignee: Siegfried Goeschl
>            Priority: Minor
>         Attachments: issue-89_patch.txt
>
>
> Please add  method to determine the size of attachment attached to email so that we can limit the attachments while sending via email

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.