❔ Where to store files in N-Tier API Project
Guys I am working on a demo n-tier architecture project I need to implement file uploads and for now I would like to store files locally. Where do you think is the best place to store them? My layers are API, DAL, Services and Entities, or should I create another solution folder called storage?
7 Replies
My personal preference would be the data layer. Treating the file access no differently than I would a database adapter/repository/etc
Repositories is actually a good abstraction over many things, including file storage
Currently I am storing them under another layer called LocalFileStorage and I have StorageService under Services layer (Services/Common) do you guys think is it bad structure??
I am thinking something like Services/Common/StorageService/IStorageService
And LocalStorageService, S3Service etc
i probably wouldn't use Common namespace, at least
I have also mappers under common is it a bad approach? and what are your suggestions where should I place it? I am a newbie so I am very lost about structuring the proejct:(
finding names and places for stuff is hard, but in the end it's always the same
if that thing is really central then it may even needs its project, if it's just 2 classes probably it doesn't
you know how it is, it will be more difficult to expand if you keep in integrated but it's less effort, and it will be easier to move and reuse if it's isolated but it more difficult
we have a lot of mappers, so we an explicit organization for that, but i would tell someone to do the same thing to everyone
also i don't how you initialize it, if you inject a service or if you have a static mapper, or if you have your software isolated in modules; it depends
same is for the files, i would have at least an interface where i can switch file storage or whatever, but i guess a service in Services is fine
say you start having a lot of repositories and maybe logic just for the files, then maybe you could create another project for that
so just keep an architecture for a feature that matches its development; it can always grow or shrink
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.