Posted on 1 Comment

Determining Absolute Path for FileEntry in Liferay

Liferay Logo

In case you are wondering how to determine the absolute path to FileEntry objects in Liferay (i.e. Document and Media Library elements) here is how it works.

First, add the following to your


Then, to calculate the absolute path for a FileEntry use the following code:

private String getDLFileAbsPath(FileEntry fileEntry) 
throws PortalException, SystemException {
  return PropsUtils.get("dl.hook.file.system.root.dir") + "/" 
    + fileEntry.getCompanyId() + "/"
    + fileEntry.getFolderId() + "/"
    + ((DLFileEntry) fileEntry.getModel()).getName() + "/"
    + fileEntry.getVersion();

Note that in order to get the foldername where your FileEntry resides you need to cast FileEntry to DLFileEntry, as shown above.

1 thought on “Determining Absolute Path for FileEntry in Liferay

  1. very useful for my new Liferay plugin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.