06,我想将文件上传到文档和库中,我已经搜索并编写了这样的代码,我得到了错误无效的属性更改日志。任何人都可以更正我的代码吗?我还有另一个疑问存储库 ID 和公司 ID 是否相同?并在 portlet 中显示您输入了无效数据。请再试一次。
public void uploadBook(ActionRequest actionRequest,
ActionResponse actionRresponse) throws PortletException,
IOException, com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
String submissionFileName = uploadRequest.getFileName("file");//uploaded filename
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
File file = uploadRequest.getFile("file");
String contentType = MimeTypesUtil.getContentType(file);
InputStream inputStream = new FileInputStream(file);
String folderName="library";
long folderId = 11502;
long repositoryId =10132;
//java.io.File file = ( java.io.File)uploadRequest.getFile("file");
// InputStream is = new FileInputStream(file);
DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.addFileEntry(themeDisplay.getUserId(),
repositoryId,
folderId,
file.getName(),
contentType,
submissionFileName,
"no description",
"changeLog",
inputStream,
file.length(),
serviceContext);
//addFileEntry(long userId, long groupId, long folderId, String name, String title, String description, String changeLog, String extraSettings, byte[] bytes, ServiceContext serviceContext)
String successMessage ="File Uploaded Successfully";
SessionMessages.add(actionRequest, "request_rocessed",successMessage);
}