Reputation: 3115
I wrote a small Web-Application using Grails. The resulting war-file is deployed on a Tomcat application server.
The app has an upload functionality for attachments. I chose to save the uploaded files to disk (rather than storing blobs in the DB).
At first i chose a filepath inside the webapp-dir to store the files, but then i realized that this dir will be overwritten with every deployment of a new war-file.
Is there a best practice for "where to store uploaded files in your local filesystem"?
Thanks for your help.
Upvotes: 7
Views: 3844
Reputation: 21
Create a separate project for upload and pass the user name for creating a user specific folder. Provide a link to this project from the main project when user wants to upload the files.
Upvotes: 2
Reputation: 1205
I guess you are looking for a best practice solution. Well, there isn't really one, but there are some places you should avoid putting them in. I' ll assume a UNIX environment.
For example:
Though I 'm not sure it is a locked specification, you could look at: linux directory structure .
The way I read it you have 3 options:
Good luck!
Upvotes: 0
Reputation: 1239
AlphaOne, we do something similar to what you are asking for, but we use an Apache webserver in front of Tomcat. We pick up the full path from the config file and write to it. Say "/tmp/branding". Then we also pick up the url path for this location from the config file (say "myapp/branding") and use this within our GSPs. Then, in Apache, we map app requests for that url ("myapp/branding") to go directly to the file location, bypassing Tomcat.
Upvotes: 2
Reputation: 12334
I would recommend using an environment variable to store the location, or better yet using an environment variable to set the location of your config properties file and setting a property there. That way the location becomes configurable by the operations team, who should be managing filesystem/configuration concerns.
Upvotes: 1