I'm storing files to a folder in a play! project and I have a question about paths. My solution is working, but I think the solution is sub optimal.
My current solution:
public static String getStoragePath(){
String pubDir = Play.application().configuration().getString("pathToFiles");
if(Play.isProd()){
String prodDir = Play.application().configuration().getString("productionPath");
//prodDir variable is "target/scala-2.9.1/classes"
return Play.application().path().getAbsolutePath() + "/" + prodDir + "/" + pubDir;
}else{
return Play.application().path().getAbsolutePath() + "/" + pubDir;
}
}
My question:
I do it like this because the paths are different when running "play run" and "play start". Is there a way to avoid using this if-block? I dont want to be dependent on the productionPath string in my configuration file.