This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I am currently tasked with writing a service method that abstracts away some of the details about how a file that is uploaded to our web application is stored. The goal here is to allow us to upgrade to a CMS in the future and not have to change a great deal of code.
I admittedly have very little experience in the File I/O area, but the general idea is that our default implementation will be writing the files to a file system and storing the path to a DB, along with some other metadata that is necessary for the application's use.
The issue I could use some help on is: "what is the best way to store the 'path' to the file if our application needs to be deployed across mutliple operating systems?"
The development boxes for unittesting are on Windows, and the production environments sit on UNIX. The server file system itself will also be a Windows system that can be accessed via Unix or Windows. In Windows it would be using the typical UNC file naming conventions like: \\<SERVER_NAME>, but in Unix we have it set up so that there is a symbolic link to the same server at /<SERVER_NAME>.
I have considered just replacing all of the File.SeperatorChars with a REGEX with a character that is OS agnostic before saving it into the DB's FILE_LOCATION column, but this seems a big ugly. Are there any other methods that you have found to work well that I could investigate?
Thanks in advance for your help,