掲示板

Message Board - Attachment

16年前 に Ady Das OToole によって更新されました。

Message Board - Attachment

New Member 投稿: 5 参加年月日: 07/04/09 最新の投稿
I'm in the process of migrating from a legacy forum to Lifery MB and have a question about Attachment storage.

Anyone know how Attachments are stored - more specifically where is the mapping between the Post (in MBMessage, Demoticon and the Attachment (In the File system) stored?
thumbnail
16年前 に Jerry Niu によって更新されました。

RE: Message Board - Attachment

Expert 投稿: 451 参加年月日: 06/06/21 最新の投稿
The files are stored in the Doc Lib, here's the code that does it:

MBMessageLocalServiceUtil/Impl::addMessage

		// File attachments

		if (files.size() > 0) {
			long companyId = message.getCompanyId();
			String portletId = CompanyImpl.SYSTEM_STRING;
			long groupId = GroupImpl.DEFAULT_PARENT_GROUP_ID;
			String repositoryId = CompanyImpl.SYSTEM_STRING;
			String dirName = message.getAttachmentsDir();

			try {
				try {
					DLServiceUtil.deleteDirectory(
						companyId, portletId, repositoryId, dirName);
				}
				catch (NoSuchDirectoryException nsde) {
				}

				DLServiceUtil.addDirectory(companyId, repositoryId, dirName);

				for (int i = 0; i < files.size(); i++) {
					ObjectValuePair ovp = (ObjectValuePair)files.get(i);

					String fileName = (String)ovp.getKey();
					byte[] byteArray = (byte[])ovp.getValue();

					try {
						DLServiceUtil.addFile(
							companyId, portletId, groupId, repositoryId,
							dirName + "/" + fileName, byteArray);
					}
					catch (DuplicateFileException dfe) {
					}
				}
			}
			catch (RemoteException re) {
				throw new SystemException(re);
			}
		}
16年前 に Ady Das OToole によって更新されました。

RE: Message Board - Attachment

New Member 投稿: 5 参加年月日: 07/04/09 最新の投稿
Thanks but how does the MBMessage row store the path to the file? I see the boolean indicating that an attachment exists but cannot see the file path stored. Does it retrieve the file from the Doc Lib some other way?
thumbnail
8年前 に Rushi Priya Panda によって更新されました。

RE: Message Board - Attachment

New Member 投稿: 5 参加年月日: 11/01/19 最新の投稿
Currently attachments are stored something like below.

document_library/<company id>/0/messageboards/<thread id>/<message id>

So when attachments are created, they are places inside the folder name created by name of the message id of the message. You can see the code in below class.

The code for this is in "portal-impl/src/com/liferay/portlet/messageboards/model/impl/MBMessageImpl.java".

And while rendering, it get retrieved like below.

existingAttachments = DLStoreUtil.getFileNames(message.getCompanyId(), CompanyConstants.SYSTEM, message.getAttachmentsDir());

message.getAttachmentsDir() =" document_library/<company id>/0/messageboards/<thread id>/<message id>"