Fórumok

Error received while uploading file to Document Library folder

Madhuri Potdar, módosítva 11 év-val korábban

Error received while uploading file to Document Library folder

New Member Bejegyzés: 1 Csatlakozás dátuma: 2012.04.02. Legújabb bejegyzések
I have created a folder in document library and then trying to upload a .xls or .xlsx file to this folder programmaticaly. This is working fine when I am trying to run it on local server. However when I am running it in shared environment, it is somehow appending .null to the file name and giving following error -
Error occured while storing input file in Document Library folder
com.liferay.documentlibrary.FileExtensionException: upload_00000383.xlsx.null

Here is the code I am using for this -

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long realUserId = themeDisplay.getRealUserId();
long groupId = themeDisplay.getLayout().getGroupId();
ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(groupId);

DLFolder folder = DLFolderLocalServiceUtil.addFolder(realUserId, groupId, 0, "TestFolderName","Test Folder Description", serviceContext);

UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);
File file = uploadPortletRequest.getFile("path");

DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.addFileEntry(realUserId,groupId,folder.getFolderId(), file.getName(), file.getName(), "", "", folderName, file, serviceContext);

Anyone having any idea why .null might be getting appended to file name during upload?
Andy Harb, módosítva 11 év-val korábban

RE: Error received while uploading file to Document Library folder

Junior Member Bejegyzések: 66 Csatlakozás dátuma: 2009.10.22. Legújabb bejegyzések
Hi Madhuri,

Where you ever able to figure this out? I am experiencing the same problem and can't track it down.

Thanks
Andy
thumbnail
Nagendra Kumar Busam, módosítva 11 év-val korábban

RE: Error received while uploading file to Document Library folder

Liferay Master Bejegyzések: 678 Csatlakozás dátuma: 2009.07.07. Legújabb bejegyzések
Hi Madhuri,

Can you explain a bit about shared environment you are referring to
- Nagendra Kumar
Andy Harb, módosítva 11 év-val korábban

RE: Error received while uploading file to Document Library folder

Junior Member Bejegyzések: 66 Csatlakozás dátuma: 2009.10.22. Legújabb bejegyzések
Figured it out:

You need to define the extension and content type in the service context as attributes:


  String contentType = uploadRequest.getContentType("file");
  serviceContext.setAttribute("contentType", contentType);
   String extension = com.liferay.portal.kernel.util.FileUtil.getExtension(file.getName());
   serviceContext.setAttribute("extension", extension);
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: Error received while uploading file to Document Library folder

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
You need to define the extension and content type in the service builder as attributes:


Just so other reader won't get confused, you mean "service context".
Andy Harb, módosítva 11 év-val korábban

RE: Error received while uploading file to Document Library folder

Junior Member Bejegyzések: 66 Csatlakozás dátuma: 2009.10.22. Legújabb bejegyzések
Thanks for the correction! Edited original post