I’m now developing a blog system’s back end. As the project is not on a big scale, we decided to use the local backend server to store users’ files, such as avatars, posts, etc.
I have learnt some of the practice in storing users’ files. Due to the budget and our project scale, using a cloud storage is not feasible; the alternatives are (I’ll use the avatars to issue my example.):
- Store each avatars with its path [project_root]/user_files/[username]/avatar.png (or .jpg etc.), and then use no field in database for users’ avatar’s path.
- Store each avatar with its path [project_root]/avatars/[UUID].png, and store the UUID in the database.
- Build a cloud storage server on my own and store the URL in database.
- Use Base64 to store each user’s avatar in text.
What is a better approach?
What is best practice to store users’ files in a web application backend server?
1