Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
David Ilechukwu
[URGENT] Best Liferay Directory to Store Private Files?
January 27, 2013 10:06 AM
Answer

David Ilechukwu

Rank: Regular Member

Posts: 114

Join Date: June 7, 2010

Recent Posts

Ok guys,
Here's a quick one

My scenario is as follows:
I need to manually (not using Liferay http upload) upload a very confidential file (actually a company certificate keystore file) to my Liferay Server, such that:
The file should NEVER be accessible over http or https
File can only be accessed in code (say using a String pathToFile parameter).
Question is - where in Liferay (Tomcat Server) would be the best place to put such a sensitive file?

I'm aware that the default system used by Liferay for saving uploaded files can be specified in portal-ext.properties, using say:
dl.store.file.system.root.dir=${liferay.home}/data/document_library.

However, that would specify the default location for uploading files (and that would obviously be accessible over http).

Questions
(1) Where in Liferay Server directory hierarchy would be the best location to store such a file?
(2) How would I access such a file in Liferay (portlet) code?

Quick responses will be highly appreciated! emoticon

Thanks Guys!
Jelmer Kuperus
RE: [URGENT] Best Liferay Directory to Store Private Files?
January 27, 2013 11:35 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

dl.store.file.system.root.dir=${liferay.home}/data/document_library is not directly directly over http

It just holds the bytes of the files stored in the document library but those files cannot be retrieved unless a DlFileEntry exists in the database that points to it.

You should probably store your file under ${liferay.home}/data/whatever
David Ilechukwu
RE: [URGENT] Best Liferay Directory to Store Private Files?
January 27, 2013 2:50 PM
Answer

David Ilechukwu

Rank: Regular Member

Posts: 114

Join Date: June 7, 2010

Recent Posts

How do you I access a file stored in ${liferay.home}/datain my source code (seems to have skipped my mind).
Please show me a sample code snippet for doing that?

Also - what do you think about storing the file in my portlet-service.jar (seems a more distributed way of doing things)?
Many Thanks

jelmer kuperus:
dl.store.file.system.root.dir=${liferay.home}/data/document_library is not directly directly over http

It just holds the bytes of the files stored in the document library but those files cannot be retrieved unless a DlFileEntry exists in the database that points to it.

You should probably store your file under ${liferay.home}/data/whatever
Vilmos Papp
RE: [URGENT] Best Liferay Directory to Store Private Files?
January 28, 2013 2:02 AM
Answer

Vilmos Papp

LIFERAY STAFF

Rank: Expert

Posts: 432

Join Date: October 21, 2010

Recent Posts

Hi David,

You can assess it through Documents and Media services, but if you would be more specific about what type you would like to upload, how frequently you want to change it that would be helpful to find a proper solution.

Regards,
Vilmos
David Ilechukwu
RE: [URGENT] Best Liferay Directory to Store Private Files?
January 28, 2013 2:21 AM
Answer

David Ilechukwu

Rank: Regular Member

Posts: 114

Join Date: June 7, 2010

Recent Posts

Vilmos Papp:
Hi David,

You can assess it through Documents and Media services, but if you would be more specific about what type you would like to upload, how frequently you want to change it that would be helpful to find a proper solution.

Regards,
Vilmos


Thanks Vilmos -
(1) This file will not be uploaded to the portal - it is simply a file that will be copied into the Liferay data directory.
(2) The file is a certificate keystore (.pfx) - it is needed by the code that generates digital signatures

Hope this makes it clearer.
How do I access this file in code is the question (preferrably using a standard File object). What path would I put as the path to the file? Is it the full path (maybe C:/LiferayPortal/data/whatever) or is it some kind of alias url within Liferay such as /data/whatever/file.pfx

Thanks for quick response.
Regards
gofri _
RE: [URGENT] Best Liferay Directory to Store Private Files?
January 28, 2013 3:49 AM
Answer

gofri _

Rank: Junior Member

Posts: 94

Join Date: March 2, 2007

Recent Posts

You can use:
1. DLStoreUtil to access files in liferay data folder, skipping Document Library objects' creation, and thus accessing them only through Your code.
2. If You need more "low-level" logic, w/o using Liferay services, You can add file in some folder and point it in portal-ext.properties
Vilmos Papp
RE: [URGENT] Best Liferay Directory to Store Private Files?
January 28, 2013 6:36 AM
Answer

Vilmos Papp

LIFERAY STAFF

Rank: Expert

Posts: 432

Join Date: October 21, 2010

Recent Posts

Hi David,

I would create a custom Deployer implementation to deploy these type of files, which would move the file into a folder on the same level of document_library. If it's done, you can check how we access these files relatively and use the same pattern in your own code.

I hope it helps.

Regards,
Vilmos