Skip to content

Instantly share code, notes, and snippets.

@pedroblandim
Created May 10, 2022 22:04
Show Gist options
  • Save pedroblandim/acb7d7ecdfc8d7961e243a3b6a7109d6 to your computer and use it in GitHub Desktop.
Save pedroblandim/acb7d7ecdfc8d7961e243a3b6a7109d6 to your computer and use it in GitHub Desktop.
Liferay get DL File preview URL
import com.liferay.document.library.kernel.service.DLAppLocalServiceUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.document.library.util.DLURLHelperUtil;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.exception.PortalException;
public static String getDLEntryFileURL(long fileEntryId, ThemeDisplay themeDisplay)
throws PortalException {
FileEntry file = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
return DLURLHelperUtil.getPreviewURL(
file, file.getFileVersion(), themeDisplay, null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment