I want to design the file storage part of my application with some flexibility, so one can store files in either S3 or on the web server's hard drive.
I also want this to be flexible on a per user basis, so in their user settings they can choose if they want their files stored in S3 or on the servers file system.
I am thinking of something like this:
IFileStorage fs = FileStorageFactory.Instance(userSettings);
Then I would have a method that looks like:
public static IFileStorage Instance(UserSettings setting)
{
if(setting == UserSettings.S3)
return new S3FileStorage();
}
Does this make sense? (I'm a c# programmer but I will be doing this in Java)
I am using Spring, but I don't think DI will be used here since the implementation changes on a per user basis.