0

06、ドキュメントやライブラリにファイルをアップロードしたいのですが、検索してこのようなコードを書いたところ、無効なプロパティ変更ログのエラーが発生しました。誰でも私のコードを修正できますか? また、リポジトリ ID と会社 ID が同じであるという別の疑いがありますか? 無効なデータを入力したことを示すポートレットに表示されます。もう一度やり直してください。

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 に答える