Fórum
Add files programmatically to CUSTOM DOCUMENT TYPE
Krishma Maniar, modificado 9 Anos atrás.
Add files programmatically to CUSTOM DOCUMENT TYPE
New Member Postagens: 6 Data de Entrada: 04/09/14 Postagens Recentes
Hi
I have made a new custom document type which has extra metadata fields.
I am uploading files programmatically, but it gets uploaded as a basic document.
How can i upload to custom document type programmatically?
I have made a new custom document type which has extra metadata fields.
I am uploading files programmatically, but it gets uploaded as a basic document.
How can i upload to custom document type programmatically?
Jitendra Rajput, modificado 9 Anos atrás.
RE: Add files programmatically to CUSTOM DOCUMENT TYPE
Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
You need to pass correct fileEntryTypeId at time of adding document using DL service. Use below method to add document with your custom type.
Make sure you pass correct fileEntryTypeId highlighted in above code.
public static com.liferay.portlet.documentlibrary.model.DLFileEntry addFileEntry(
long userId, long groupId, long repositoryId, long folderId,
java.lang.String sourceFileName, java.lang.String mimeType,
java.lang.String title, java.lang.String description,
java.lang.String changeLog, l[b]ong fileEntryTypeId[/b],
java.util.Map<java.lang.string, com.liferay.portlet.dynamicdatamapping.storage.fields> fieldsMap,
java.io.File file, java.io.InputStream is, long size,
com.liferay.portal.service.ServiceContext serviceContext)
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return getService()
.addFileEntry(userId, groupId, repositoryId, folderId,
sourceFileName, mimeType, title, description, changeLog,
fileEntryTypeId, fieldsMap, file, is, size, serviceContext);
}</java.lang.string,>
Make sure you pass correct fileEntryTypeId highlighted in above code.
Krishma Maniar, modificado 9 Anos atrás.
RE: Add files programmatically to CUSTOM DOCUMENT TYPE
New Member Postagens: 6 Data de Entrada: 04/09/14 Postagens Recentes
Hi Jitendra,
thanks for your help,
i tried this:
InputStream in = new BufferedInputStream(
uploadPortletRequest.getFileAsStream("fileupload"));
DLFolder dlFolder = DLFolderLocalServiceUtil.getFolder(
themeDisplay.getScopeGroupId(), 0, "folder name");
System.out.println("Folder ID" + dlFolder.getFolderId());
ServiceContext sc = new ServiceContext();
DLFileEntry name = DLFileEntryLocalServiceUtil.addFileEntry(userId, themeDisplay.getScopeGroupId(),
themeDisplay.getScopeGroupId(), dlFolder.getFolderId(), fileName, MimeTypesUtil.getContentType(file), "title:T", "description",
"changeLog", 21311 , null, file, in, file.length(), sc);
//setting form fields
//save method
i have passed the fileEntryTypeId as 21311, but its not adding files.
is it the right way to do it?
or should i try something like FileEntry getFileEntry(long groupId, long folderId, String title) method
I am using liferay 6.2
thanks for your help,
i tried this:
InputStream in = new BufferedInputStream(
uploadPortletRequest.getFileAsStream("fileupload"));
DLFolder dlFolder = DLFolderLocalServiceUtil.getFolder(
themeDisplay.getScopeGroupId(), 0, "folder name");
System.out.println("Folder ID" + dlFolder.getFolderId());
ServiceContext sc = new ServiceContext();
DLFileEntry name = DLFileEntryLocalServiceUtil.addFileEntry(userId, themeDisplay.getScopeGroupId(),
themeDisplay.getScopeGroupId(), dlFolder.getFolderId(), fileName, MimeTypesUtil.getContentType(file), "title:T", "description",
"changeLog", 21311 , null, file, in, file.length(), sc);
//setting form fields
//save method
i have passed the fileEntryTypeId as 21311, but its not adding files.
is it the right way to do it?
or should i try something like FileEntry getFileEntry(long groupId, long folderId, String title) method
I am using liferay 6.2
Tanweer Ahmed ., modificado 1 Ano atrás.
RE: Add files programmatically to CUSTOM DOCUMENT TYPE
Expert Postagens: 322 Data de Entrada: 11/03/10 Postagens Recentes
Hi Krishma,
In LR6.2, you should use DLApp.
Hope this helps.
Regards,
Tanweer.
In LR6.2, you should use DLApp.
long folderId = DLAppLocalServiceUtil.addFolder(userId, repositoryId, folderId, name, description,
folderServiceContext).getFolderId();
FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, repositoryId, folderId, title, mimeType, title,
description, changeLog, file, serviceContext);
Hope this helps.
Regards,
Tanweer.
Jitendra Rajput, modificado 9 Anos atrás.
RE: Add files programmatically to CUSTOM DOCUMENT TYPE
Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
Any error coming while adding document ? You can also use methods suggested by Tanweer which is internally communicating with dLFileEntry service.
Krishma Maniar, modificado 9 Anos atrás.
RE: Add files programmatically to CUSTOM DOCUMENT TYPE
New Member Postagens: 6 Data de Entrada: 04/09/14 Postagens Recentes
Hi Tanweer,
Thanks for helping..
Your method helped me to insert files.
But however my requirement is:
1) i have a custom document type with extra metadata fields(eg. interviewers name, eligible for next round)
2) so when i upload a file (resume), i want it to be uploaded as that custom document type.
Also when i am uploading the file, i should be able to fill those extra metadata fields manually.
Is it possible? & how?
Hi Jintendra, when i tried the DLFile entry, it didnt give me any error on console, but i got an error on liferay page "Your request failed to complete".
Thanks for helping..
Your method helped me to insert files.
But however my requirement is:
1) i have a custom document type with extra metadata fields(eg. interviewers name, eligible for next round)
2) so when i upload a file (resume), i want it to be uploaded as that custom document type.
Also when i am uploading the file, i should be able to fill those extra metadata fields manually.
Is it possible? & how?
Hi Jintendra, when i tried the DLFile entry, it didnt give me any error on console, but i got an error on liferay page "Your request failed to complete".
Krishma Maniar, modificado 9 Anos atrás.
RE: Add files programmatically to CUSTOM DOCUMENT TYPE
New Member Postagens: 6 Data de Entrada: 04/09/14 Postagens Recentes
If you have any other approach to achieve this then please share.
Ramalingaiah. D, modificado 7 Anos atrás.
RE: Add files programmatically to CUSTOM DOCUMENT TYPE
Expert Postagens: 486 Data de Entrada: 16/08/14 Postagens Recentes
Hi Krishma Maniar,
I was done uploading files through DL_App_Service into dms project successfully.
but i cant uploading files along with the custom metadata and its document type through web services into the dms project.
Rereads
Ram
I was done uploading files through DL_App_Service into dms project successfully.
but i cant uploading files along with the custom metadata and its document type through web services into the dms project.
Rereads
Ram