<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Portlet Upload File Issue</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112223724" />
  <subtitle>Portlet Upload File Issue</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112223724</id>
  <updated>2026-04-06T20:10:43Z</updated>
  <dc:date>2026-04-06T20:10:43Z</dc:date>
  <entry>
    <title>RE: Portlet Upload File Issue</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112276831" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112276831</id>
    <updated>2019-02-08T12:19:29Z</updated>
    <published>2019-02-08T12:19:29Z</published>
    <summary type="html">&lt;blockquote&gt;John CressmanI&amp;#39;m having an issue when I try to process an uploaded file in my portlet.&lt;br /&gt;&lt;br /&gt;When I try to upload a graphics file or PDF, it works.  When I try a DOCX file or other type it fails.&lt;br /&gt;&lt;br /&gt;In the server log, it has the full path to the file and says it can&amp;#39;t be found.  The error occurs when I try to attach the file to the email.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;My best guess is: It&amp;#39;s a temporary file. MailServiceUtil will asynchronously send the file from a different thread, when the current request is long done. I&amp;#39;m not sure when temporary files are deleted - also not if they&amp;#39;re taken into memory for construction of the message, or if the mail API relies on the file to still be there when the mail is being sent. I suspect that the observed file type correlation is just by chance.&lt;br /&gt;&lt;br /&gt;Another less likely option, in case you&amp;#39;re on Windows, might be an Antivirus over-eagerly quarantining a file, if it&amp;#39;s indeed dependent on the doctype.</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2019-02-08T12:19:29Z</dc:date>
  </entry>
  <entry>
    <title>Portlet Upload File Issue</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112223723" />
    <author>
      <name>John Cressman</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112223723</id>
    <updated>2019-02-04T13:41:53Z</updated>
    <published>2019-02-04T13:41:53Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I'm having an issue when I try to process an uploaded file in my portlet.&lt;br&gt;&lt;br&gt;When I try to upload a graphics file or PDF, it works.&amp;nbsp; When I try a DOCX file or other type it fails.&lt;br&gt;&lt;br&gt;In the server log, it has the full path to the file and says it can't be found.&amp;nbsp; The error occurs when I try to attach the file to the email.&lt;br&gt;&lt;br&gt;&lt;br&gt;Part of my Class file&lt;br&gt;&lt;pre&gt;&lt;code&gt;private final static String baseDir = "/tmp/uploaded/";
private final static String fileInputName = "theFile";


@ProcessAction(name="myActionMethod")
public void myActionMethod(ActionRequest request, ActionResponse response) throws Exception {

        File uploadedFile = null;
        try {
                UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
                if (uploadRequest.getSize(fileInputName) == 0) {
                        throw new Exception("Received file is 0 bytes!");
                }
                uploadedFile = uploadRequest.getFile(fileInputName);

        } catch (Exception e) {
                LOG.error(e.toString(),e);
        }





        User myUser = PortalUtil.getUser(request);

        String from = "noreply@lvh.com";
        String sendTo = "john.cressman@lvhn.org";

        InternetAddress myFrom = new InternetAddress(from, from);
        InternetAddress myTo = new InternetAddress(sendTo, sendTo);

        String subject = "New URL Request";

        String innerName = ParamUtil.getString(request, "theName");
        String innerApp = ParamUtil.getString(request, "theApp");
        String innerAppType = ParamUtil.getString(request, "theAppType");
        String innerPurpose = ParamUtil.getString(request, "thePurpose");
        String innerDept = ParamUtil.getString(request, "theDept");
        String innerUsers = ParamUtil.getString(request, "theUsers");
        String innerDTS = ParamUtil.getString(request, "theDTS");
        String innerDCS = ParamUtil.getString(request, "theDCS");
        String innerDS = ParamUtil.getString(request, "theDS");
        String innerDSS = ParamUtil.getString(request, "theDSS");
        String innerDSE = ParamUtil.getString(request, "theDSE");
        String innerST = ParamUtil.getString(request, "theST");
        String innerBackup = ParamUtil.getString(request, "theBackup");
        String innerOSS = ParamUtil.getString(request, "theOSS");
        String innerAudit = ParamUtil.getString(request, "theAudit");
        String innerAuditMgt = ParamUtil.getString(request, "theAuditMgt");
        String innerAccounts = ParamUtil.getString(request, "theAccounts");
        String innerAuth = ParamUtil.getString(request, "theAuth");
        String innerRS = ParamUtil.getString(request, "theRS");
        String innerVendorInfo = ParamUtil.getString(request, "theVendorInfo");
        String innerVC = ParamUtil.getString(request, "theVC");
        String innerBAA = ParamUtil.getString(request, "theBAA");
        String innerProject = ParamUtil.getString(request, "theProject");

        String innerSUI = ParamUtil.getString(request, "theSUI");
        String innerMgrSUI = ParamUtil.getString(request, "theMgrSUI");
        String innerMgrEmail = ParamUtil.getString(request, "theMgrEmail");
        String innerUserEmail = ParamUtil.getString(request, "theUserEmail");

        InternetAddress[] myCC = InternetAddress.parse(innerUserEmail + "," + innerMgrEmail);
        //InternetAddress[] myCC = InternetAddress.parse(innerUserEmail + "," + innerUserEmail);

        String mailBody = "Security Team, \n\nThe following request has been received the following request:\n\n";

        mailBody += "Submitter: " + innerSUI + "\n";
        mailBody += "Submitter Manager: " + innerMgrSUI + "\n";

        mailBody += "Analyst: " + innerName + "\n";
        mailBody += "Name of Application: " + innerApp + "\n";
        mailBody += "Type of Application: " + innerAppType + "\n";
        mailBody += "Business Purpose: " + innerPurpose + "\n";
        mailBody += "Department Requesting: " + innerDept + "\n";

        mailBody += "Users: " + innerUsers + "\n";
        mailBody += "Data Transfer Security: " + innerDTS + "\n";
        mailBody += "Data Center Storage: " + innerDCS + "\n";
        mailBody += "Data Storage: " + innerDS + "\n";
        mailBody += "Data Storage Segmentation: " + innerDSS + "\n";
        mailBody += "Data Storage Encryption: " + innerDSE + "\n";
        mailBody += "Securing Traffic: " + innerST + "\n";
        mailBody += "Backup: " + innerBackup + "\n";
        mailBody += "Off Site Storage: " + innerOSS + "\n";
        mailBody += "Auditing: " + innerAudit + "\n";
        mailBody += "Auditing Management: " + innerAuditMgt + "\n";
        mailBody += "Account Management: " + innerAccounts + "\n";
        mailBody += "Authentication: " + innerAuth + "\n";
        mailBody += "Role Security: " + innerRS + "\n";
        mailBody += "Vendor Info: " + innerVendorInfo + "\n";
        mailBody += "Vendor Certification: " + innerVC + "\n";
        mailBody += "Business Associates Agreement: " + innerBAA + "\n";
        mailBody += "Project Reference: " + innerProject + "\n";


        try {
                MailMessage mailMessage = new MailMessage();

                mailMessage.setFrom(myFrom);
                mailMessage.setTo(myTo);
                mailMessage.setCC(myCC);

                mailMessage.setSubject(subject);
                mailMessage.setBody(mailBody);

                [color=#ff0000]mailMessage.addFileAttachment(uploadedFile);[/color]


                MailServiceUtil.sendEmail(mailMessage);
        } catch (Exception e) {
                //e.printStackTrace();
                LOG.error(e.toString(),e);
        }

        response.setRenderParameter("jspPage", "/finish.jsp");

}&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;My view.jsp&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;aui:form name="myForm" action="${myaction}" method="post"&amp;gt;

   &amp;lt;aui:input label="Analyst" name="theName" required="true" value="" placeholder="Enter your first and last names" class="textbox1" /&amp;gt;

   &amp;lt;aui:input label="Application" name="theApp" required="true" value="" placeholder="Enter Application Name" class="textbox1" /&amp;gt;

   &amp;lt;aui-select id="theAppType" name="theAppType" placeholder="Select One" required="true"&amp;gt;
            &amp;lt;aui-option&amp;gt;Internal Application with PHI&amp;lt;/aui-option&amp;gt;
            &amp;lt;aui-option&amp;gt;Internal Application with No PHI&amp;lt;/aui-option&amp;gt;
            &amp;lt;aui-option&amp;gt;External Application with PHI&amp;lt;/aui-option&amp;gt;
            &amp;lt;aui-option&amp;gt;External Application with No PHI&amp;lt;/aui-option&amp;gt;
        &amp;lt;/aui-select&amp;gt;

   &amp;lt;aui:input type="textarea" label="Business Purpose" name="thePurpose" required="true" value="" placeholder="Please provide a brief overview of the product and how it will be used at LVHN" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Department Requesting" name="theDept" required="true" value="" placeholder="What is the department requesting the application, and will it be used outside the requesting department?" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Users" name="theUsers" required="true" value="" placeholder="Approximate number of users of the application" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Data Transfer Security" name="theDTS" required="true" value="" placeholder="What method is being used to secure the traffic to and from the application? (Some examples include https, sftp, etc)" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Data Center Storage" name="theDCS" required="true" value="" placeholder="Is the data stored at the vendor's data center or a third-party data center?" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Data Storage" name="theDS" required="true" value="" placeholder="Where is the data stored once received by the vendor? (Some examples include database server, san storage, etc" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Data Storage Segmentation" name="theDSS" required="true" value="" placeholder="Is the LVHN data segmented from other companies sending data to the vendor and how? (Some examples include firewall segmentation, private server, etc)" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Data Storage Encryption" name="theDSE" required="true" value="" placeholder="Is the data at rest encrypted? If so, using what encryption standard? (Some examples include AES 256, DES 56, etc)" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Securing Traffic" name="theST" required="true" value="" placeholder="What method is being used to secure the traffic to and from the application? (Some examples include https, sftp, etc)" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Backup" name="theBackup" required="true" value="" placeholder="Is the data backed up and if so, are the backups encrypted?" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Off Site Storage" name="theOSS" required="true" value="" placeholder="Are any of the backup tapes stored offsite?" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Auditing" name="theAudit" required="true" value="" placeholder="What level of audit logs are available from the application? (Some examples include user activity level, log on activity level ,etc)" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Auditing Management" name="theAuditMgt" required="true" value="" placeholder="How are the audit logs obtained and who will have access to these logs?" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Account Management" name="theAccounts" required="true" value="" placeholder="Who will create the users?" /&amp;gt;

   &amp;lt;aui:input type="textarea" label="Authentication" name="theAuth" required="true" value="" placeholder="How is the user authenticated to the application? (Some example include AD authentication, unique accounts, etc)" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Role Security" name="theRS" required="true" value="" placeholder="Are there different levels or roles that can be assigned with different priveledges for different users?" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Vendor Info" name="theVendorInfo" required="true" value="" placeholder="Is there a specific contact resource assigned to LVHN? If so, please provide contact details." /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Vendor Certification" name="theVC" required="true" value="" placeholder="Does the vendor have SSAE 16 or DOC certification available for review by LVHN IS Security Management?" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Business Associates Agreement" name="theBAA" required="true" value="" placeholder="Is a BAA signed with the vendor and if so, has a copy been provided to the LVHN Privacy Officer?" /&amp;gt;
   &amp;lt;aui:input type="textarea" label="Project Reference" name="theProject" required="true" value="" placeholder="Is this request associated with a specific project?" /&amp;gt;

   &amp;lt;aui:input label="Please attach any documentation you have for the application that will aid the approval process" type="file" name="theFile" /&amp;gt;

   &amp;lt;aui:input type="hidden" name="theSUI" value="${sui}" /&amp;gt;
   &amp;lt;aui:input type="hidden" name="theMgrSUI" /&amp;gt;
   &amp;lt;aui:input type="hidden" name="theMgrEmail" /&amp;gt;
   &amp;lt;aui:input type="hidden" name="theUserEmail" /&amp;gt;

    &amp;lt;aui:button type="submit" name="submit" value="submit" /&amp;gt;
&amp;lt;/aui:form&amp;gt;

&amp;lt;aui:script&amp;gt;&amp;lt;/aui:script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;Any ideas why it would allow some files and not others?&amp;nbsp; Size doesn't seem to matter.&amp;nbsp; It just seems to be the type of file.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>John Cressman</dc:creator>
    <dc:date>2019-02-04T13:41:53Z</dc:date>
  </entry>
</feed>
