0

I have a requirement to fetch the original file-name of the uploaded file when the file is downloaded from Documents & Media.

Here is what is happening now

  1. Upload basic-document, original file name: test01.xml
  2. Give the title to the document as Testing Java
  3. submit and upload
  4. Now for users it would appear as Testing Java and when i download it would download the file with the name Testing Java.xml.

Q. I want that the downloaded file be named as test01.xml, is this possible?

Is there anyway through the API that this can be done?

Thanks

Prakash K
  • 11,669
  • 6
  • 51
  • 109

1 Answers1

3

Basically you can not achieve this with original Liferay sources, without any custom work done. This is because, the only one name stored in DlFileEntry table is the one given by user (except the situation, when no name was defined - then original one is taken). This means original one is forgotten once, you upload document.

My own proposal to achieve it, would be creating custom field for Documents and Media, and then if this is your custom mechanism responsible for downloading, just using this name instead of standard name in first place. Still, if you want to fill this field automatically, there seems to be no way to avoid some hook/ext work.

tomic
  • 603
  • 3
  • 10
  • Thank you for your answer. thanks for confirming that liferay does not store the original name. With custom hook, it would be like when we upload the document we need to fill the hidden custom-field programmatically and also while downloading implement our custom action to take name from the custom-field. Is this what you are hinting at? – Prakash K May 19 '15 at 08:54
  • Yup, I just wanted to keep original functionality, this is why pointed at custom field. – tomic May 19 '15 at 09:00