Forums

Home » Liferay Portal » English » Liferay Legacy

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
nrussell nrussell
multipart/form-data
February 1, 2005 1:29 PM
Answer

nrussell nrussell

Rank: New Member

Posts: 2

Join Date: January 31, 2005

Recent Posts

I have written a portlet that extends GenericPortlet. My intent is to wrap the ActionRequest for all classes that extend my new portlet that you could just call the request.getParameter for multipart form data and non multipart form data. The problem is that I am relying on the request.getContentType() to return &quot;multipart/form-data&quot; that is set on the form&#39;s enctype. This works on pluto but I get null from liferay. Is there another way for me to determine this?<br /><br />Thanks
Brett Randall
multipart/form-data
February 2, 2005 2:35 PM
Answer

Brett Randall

Rank: Liferay Legend

Posts: 1254

Join Date: August 17, 2004

Recent Posts

Liferay&#39;s MainServlet deliberately wraps any multipart/form-data request in an UploadServletRequest (which hides the real content-type), to prevent Struts from processing multipart requests (Struts also tries to wrap it in a 2.2 servlet-compliant, home-grown wrapper).<br /><br />I&#39;m not entirely sure why this is done, but it appears that UploadServletRequest attempts to simplify things by encapsulating the entire multipart in Commons fileupload.<br />
Enrique Ruiz
multipart/form-data
April 25, 2005 8:48 AM
Answer

Enrique Ruiz

Rank: Junior Member

Posts: 37

Join Date: August 24, 2004

Recent Posts

Hi, we are trying to upload files using a JSR-168 compliant portlet, but we have found that the ActionRequest.getContentType() method always returns null. We have supossed that it is due to the UploadServletRequest.<br /><br />We believe that this behaviour does not allow to deploy JSR-168 compliant portlets to receive files. Is it true?<br /><br />The portlet specification says:<br /><i>Depending on the underlying web-server/servlet-container and the portal/portlet container implementation, client request HTTP headers may not be always available. Portlets should not rely on the presence of headers to function properly. The<br />PortletRequest interface provides specific methods to access information normally available as HTTP headers: content-length, content-type, accept-language. Portlets should use the specific methods for retrieving those values as the portal/portlet-container implementation may use other means to determine that information.</i><br /><br />We think that Liferay is failing to fulfill this part of the specification.
Brian Chan
multipart/form-data
April 25, 2005 3:00 PM
Answer

Brian Chan

LIFERAY STAFF

Rank: Liferay Master

Posts: 751

Join Date: August 4, 2004

Recent Posts

This was now fixed in CVS 2-3 weeks ago. I think you can get away with just updating util-java/* and upgrading to the latest lib/commons-fileupload.jar plus lib/commons-io.jar from CVS.<br />
Enrique Ruiz
multipart/form-data
April 25, 2005 10:59 PM
Answer

Enrique Ruiz

Rank: Junior Member

Posts: 37

Join Date: August 24, 2004

Recent Posts

Great&#33;&#33;<br /><br />Thanks.<br />
chiffa chiffa
multipart/form-data
August 15, 2005 3:05 AM
Answer

chiffa chiffa

Rank: New Member

Posts: 2

Join Date: August 14, 2005

Recent Posts

I&#39;m working on JSR 168 portable app and I would like to perform the fileupload independend on the Liferay utilities. I was tried to use commons-fileupload-1.1-dev, but it returns the incorrect file data after uploading file on server in liferay 3.5 case. But Pluto, Gridsphere and uPortal works fine. Please, advice.<br /><br />Can I upload files to portlet on Liferay 3.5 not using the PortalUtil and UploadPortletRequest?<br /><br />Is this issue still exist in Liferay 3.6.1??
zeroconf zeroconf
multipart/form-data
September 17, 2005 3:26 AM
Answer

zeroconf zeroconf

Rank: New Member

Posts: 24

Join Date: June 13, 2005

Recent Posts

Hi chiffa,<br /><br />I&#39; also working on JSR 168 compliant portlets trying to upload files with common-fileupload lib <br />/Version 1.1-dev) but the file gets corrupted. I&#39; using Liferay 3.6.1 Pro (the prebundled version) with <br />Java 1.5.0_04 on Linux 2.6.13<br /><br />But I think this must be available - how else can you write JSR 168 conform file upload portlets? <br />I haven&#39;t checked if this is already in JIRA bug tracker - but if not I think it should be posted there<br /><br />@bchan<br />are you really shure that this &quot;bug&quot; is fixed ??<br /><br />zeroconf
Enrique Ruiz
multipart/form-data
November 21, 2005 4:28 AM
Answer

Enrique Ruiz

Rank: Junior Member

Posts: 37

Join Date: August 24, 2004

Recent Posts

Hi all, <br /><br />We have fixed this feature in our local copy of the Liferay&#39;s source code. We have tested it with our JSR-168 portlets and it works perfectly. Next, you will found the changes that we have introduced in the Liferay code. All the changes have been done in the com.liferay.util.servlet.UploadServletRequest class.<br /><ul><li>Remove the getContentType() (only for Liferay 3.2. Liferay 3.5+ doesn&#39;t have this method)</li><li>In the constructor, remove the code that parses the InputStream:<br />
 1
 2    public UploadServletRequest&#40;HttpServletRequest req&#41; throws IOException {
 3          super&#40;req&#41;;
 4          _params = new LinkedHashMap&#40;&#41;;
 5         /*  BEG&#58;  Fix
 6        try {
 7            DiskFileUpload diskFileUpload = new LiferayDiskFileUpload&#40;
 8                new LiferayFileItemFactory&#40;DEFAULT_TEMP_DIR&#41;, req&#41;;
 9...
10...
11                _params.put&#40;fileItem.getFieldName&#40;&#41;, fileItems&#41;;
12            }
13        }
14        catch &#40;FileUploadException fue&#41; {
15            fue.printStackTrace&#40;&#41;;
16        }
17                END&#58; Fix */
18    }
</li></ul><br />By comment this code, the InputStream of the incoming request is parsed correctly in a Portlet.<br /><br />I suppose the problem was the InputStream was parsed two times.<br /><br />On the other hand, I am sure that to remove the InputStream parsing in the constructor will have side effects if you use of the Struts portlets included with Liferay. We have tested it with our own portlets, using the FileUpload 1.1-dev, and it works perfectly.<br /><br />I have seen some changes in Liferay 4.0 into the cvs but I don&#39;t know if it corrects this problem.<br /><br />Regards.<br />
Arsh g
RE: multipart/form-data
April 5, 2011 10:15 PM
Answer

Arsh g

Rank: New Member

Posts: 11

Join Date: February 18, 2011

Recent Posts

HI, I am new to liferay...
My html form contains multipart/form data for file uploading.
and also i used liferay captcha " <liferay-ui:captcha url="<%= captchaURL %>" />"
the problem is: for validating captcha i need portlet session(and i get this by using "ActionRequest") but using multipart/form Action Request is converted to the "UploadPortletRequest". so i m enable to validate captcha. plz any one has solution.
Asier Hernández
RE: multipart/form-data
April 13, 2012 5:57 AM
Answer

Asier Hernández

Rank: New Member

Posts: 21

Join Date: February 1, 2011

Recent Posts

Have you found any solution to this isuue??

I have the same problem with captcha and multipart/form data.

Thanks in advance.