Goldbones
Goldbones

Reputation: 1457

Folder Destination - Upload Files

I have a program which permits to upload a file from somewhere into another place. This another place is the path that will be on database. Where should I upload this file:

  1. Into c://?
  2. Into projectSomething/ (I´m working with glassfish and in this folder it saves on C:\Users\Alvaro\Documents\glassfish-4.0\glassfish\domains\domain1\config)
  3. Into projectSomething/src/

Upvotes: 1

Views: 145

Answers (1)

Serge Ballesta
Serge Ballesta

Reputation: 148965

Answers to such questions are always (at least partially) opinion based which is bad on SO. But I'll try to give you what is considered as good practice.

As you speak of glassfish, I suppose it is a web application. For evident security reasons, you should never allow uploaded files where you could have any of your application files. You should also think that some servlet containers or Java EE servlet can display an application without exploding the war. It is clear that in such cases, you won't be able to write anything under your project root!

So where can you put it? IMHO, the best is to see that as a deployment detail and configure it in a property file, a java system property or in a environment variable and clearly identify that in your documentation. That way it is no longer your problem as a programmer. You will be able to deploy it under windows or linux (where C:/ does not exists) under a special directory under your project root if it is guaranteed that the war will be exploded and the application will have appropriate permissions on that directory.

Upvotes: 1

Related Questions