フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド数 [ 前へ | 次へ ]
Koen Cleynhens
File upload is not working in my custom portlet!
2010/06/30 7:27
答え

Koen Cleynhens

ランク: Junior Member

投稿数: 83

参加年月日: 2010/02/23

最近の投稿

I made a custom portlet for working with current web application functionality.

One of this functionalities is a simpel file upload, but this is not working correctly in Liferay.

I use encoding = "multipart/form-data" in my form definition.

Problem is when the run engine arrives in the doRender method And I want to make a MultipartParser it is going in error.


HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);
...
MultipartParser mp = new MultipartParser(request, 10*1024*1024);



Error is :


010-06-30 16:06:24,716 ERROR [portal-web.docroot.html.portal.status.jsp] - <java.io.IOException: Corrupt form data: premature ending>
java.io.IOException: Corrupt form data: premature ending
at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:154)
at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:81)


Can someone please help me?
Nidhi Singh
RE: File upload is not working in my custom portlet!
2010/06/30 22:55
答え

Nidhi Singh

LIFERAY STAFF

ランク: Regular Member

投稿数: 155

参加年月日: 2009/10/07

最近の投稿

Hi,

Are you using any framework like struts?

you can see documentlibrary portlet functionality for upload file.

Thanks
Nidhi Singh
Koen Cleynhens
RE: File upload is not working in my custom portlet!
2010/06/30 23:49
答え

Koen Cleynhens

ランク: Junior Member

投稿数: 83

参加年月日: 2010/02/23

最近の投稿

The problem is that I don't use Struts, we are using our own J2EE framework (where I made a portlet for)

In this framework we are using the MultipartParser from Oreily to do the upload.

Without Liferay (so stand alone web request -servlet calls-) this is working. Same test in our portlet in Liferay gives this error...
Koen Cleynhens
RE: File upload is not working in my custom portlet!
2010/07/01 6:51
答え

Koen Cleynhens

ランク: Junior Member

投稿数: 83

参加年月日: 2010/02/23

最近の投稿

Ok,

I found a piece of the solution: Liferay is doing already the processing for the multipart form with commons apache library itself!

So next problem is then to capture the file which is stored by Liferay.

The point is that I have my own portlet to process my action calls for my framework.

Instead of process my action in the method processAction(ActionRequest actionRequest, ActionResponse actionResponse) I do it in the doView(RenderRequest renderRequest, RenderResponse renderResponse)


The point is now: I can capture the stored uploaded file with next code in the processAction method

UploadPortletRequest request2 = PortalUtil.getUploadPortletRequest(actionRequest);
if (request2 != null && request2.getFileName("attachmentFile") != null)
File test = request2.getFile("attachmentFile");

BUT, If I want to have this file in my doView method I have to use (because not available of the actionRequest object!! in the doRender method...):

UploadServletRequest request3 = PortalUtil.getUploadServletRequest(request);
if (request3 != null && request3.getFileName("attachmentFile") != null)
File test1 = request3.getFile(request3.getFileName("attachmentFile"));

=> in the UploadServletRequest object I do not find my File!!!

Anybody a solution?