1
我創建了一個將圖像文件上傳到圖像庫的Liferay portlet。我已經能夠通過IGImageLocalServiceUtil以編程方式從我的Liferay服務器添加和檢索圖像,但我似乎無法看到控制面板下的圖像庫portlet中的圖像。我懷疑這與許可問題有關。你能幫我找出我的代碼中有什麼問題嗎?謝謝。以編程方式將圖像添加到Liferay圖像庫
long userId = themeDisplay.getUserId();
long groupId = themeDisplay.getLayout().getGroupId();
String newFilename = "test";
long folderId = 0;
String[] permissions = { "VIEW" };
serviceContext.setCommunityPermissions(permissions);
serviceContext.setGuestPermissions(permissions);
igImage = IGImageLocalServiceUtil.addImage(userId, groupId, folderId, newFilename, "", sourceFile, "image/png" ,serviceContext);
IGImageLocalServiceUtil.addImageResources(igImage, serviceContext.getCommunityPermissions(), serviceContext.getGuestPermissions());
請指定您正在使用的Liferay Portal版本。在最新版本的Liferay Portal中,您的代碼不會編譯。 –
Liferay 6.0.6。爲什麼這不會編譯? – Gian
因爲在Liferay Portal 6.1中,「圖片庫」和「文檔庫」Portlet都合併爲「文檔和媒體」Portlet,所以API已更改且IGImageLocalServiceUtil不再存在。但這不是你的問題。 –