0

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);
    }
4

1 回答 1

0

您可以参考 EditFileEntryAction.java 方法 updateFileEntry(..) 了解要传递的参数。

默认情况下,repositoryId 是 groupId,您将在其中添加文档(即站点或组织)。

FolderId 必须是该组(站点或组织)的现有文件夹 ID

changeLog 将其作为空白“”传递

粘贴来自 Tomcat 的完整堆栈跟踪/日志

于 2013-10-04T05:20:43.610 回答