Created
September 14, 2023 03:13
-
-
Save marcosblandim/d823780fc99b05a620af936dc8de3c0d to your computer and use it in GitHub Desktop.
Create DL File from text in Liferay Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.liferay.document.library.kernel.service.DLAppLocalServiceUtil | |
import com.liferay.petra.string.StringPool | |
import com.liferay.portal.kernel.service.ServiceContextThreadLocal | |
import java.nio.charset.StandardCharsets | |
void createDLFile(String filnameWithExtension, long folderId, String mimeType, String title, String description, String text) { | |
def serviceContext = ServiceContextThreadLocal.getServiceContext() | |
def inputStream = new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)) | |
DLAppLocalServiceUtil.addFileEntry( | |
serviceContext.getUserId(), serviceContext.getScopeGroupId(), folderId, | |
filnameWithExtension, mimeType, title, | |
description, StringPool.BLANK, inputStream, | |
0, serviceContext) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment