I don’t think assets is the right folder for it. Should I create a new directory for it? What is the best practice in Phoenix projects? Think of users generated pdf files or uploaded images etc.
You are right to think assets is not the place… it should be either a place served by plug static, or anywhere, served by a controller.
I prefer the second, as it allows access checking.
The best practice is some sort of Cloud Storage. S3, Cloud Storage, Digital Ocean’s cloud spaces, etc. If you store it on the server there is no good way to run multiple nodes, and cloud storage generally allows you to provide the end user with signed links that let them download the objects directly without routing the data through your server.
I also use the ex_aws APIs for this, but there are other options too.
For us, we have to store lots of images (avatars and memories) for people, so something like S3 is great and you can always adapt to any cloud provider that has a S3 API support, like Storj.
We are storing already encrypted data files in the cloud (so the cloud provider just gets an encrypted blob and then adds their own encryption on top of that) and then handling the temporary decryption and storage with ETS during someone’s session.
I reached out to my hosting provider and they also agreed that cloud storage is the way to go especially if you plan to support your system at scale (images can add up!).
Then, if your service scales enough you can always hire a team and start to build out your own cloud.
But, yea the agreed best practice is to go to the cloud if you’re planning to grow and then revisit from there.
Controller: I’m less familiar here but you can use the same ex_aws APIs and Waffle or other for transformations.