Tony
Tony

Reputation: 19151

What should my directory structure look like for user assets in a web application?

In my web application, each user will have a logo. I am pretty sure each user will also have a photo gallery in the future. What is the best way to set up a directory structure for managing user logos and possibly other assets such as photos? Also would be good to get people's opinions on what to store in the database. My application is a Rails app.

Just to be clear, this web application will need to scale to possibly hundreds of thousands of users.

Upvotes: 0

Views: 739

Answers (2)

EmFi
EmFi

Reputation: 23450

There are plugins that offer drop in functionality for the things you're looking to do.

Essentially they work similarly to what Pindatjuh suggests. But you should check out attachment-fu and paperclip to see how the others have done it.

Upvotes: 2

Pindatjuh
Pindatjuh

Reputation: 10526

If it's a small web application and you have a database:

One folder containing all avatars (logos). In the database you set the filename of the avatar. Also another folder containing all photo's in a gallery. In the database you have one entry for each asset, pointing to the resource and user.

If it's a bigger, or growing, application, you can automatically create more folders (scripted: each 100 files create a new folder), or even load-balancing by having more than one server solely providing assets.

If you don't have a database:

Create a folder per user, which contains their avatar and assets. This one does not grow, since you don't have a database which points to the user-assets: if you have more than one server, you can't say "which" server the resources are on.

Upvotes: 0

Related Questions