Frage

I am creating my web application and need your suggestion about organizing media files and folders. So what I have right now is structure like this:

In the root I have folder images/myappName/ where I am going to save all files related to this application. This application will have different posts and each post can have few images (6~10), so I don't know how properly do the saving part. I have two options:

1) I can create each folder for each post, name them their ID, in images/myappName/ and save images for each post under their folder, something like if post's id is 1154 image container folder will be images/myappName/1154/example.jpg

2) Save all images at the same location, but their name will start by their ID. Something like if post ID is 1154 the image names will be images/myappName/1154_example.jpg

So what do you recommend guys? Which one is better option, what downsides each option can have and what else can you recommend?

Keine korrekte Lösung

Andere Tipps

if your app is going to store user's images and files, you should consider storing these into a DB as LOB data instead of using the file system, so if one day you decide to cluster your app, it can scale.

Update- if you don't want to store blobs, you can have the best of both worlds storing file metadata in the db. So you'd have freedom to add tags to your files without the worry about how these files must be organized physically in the file system

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top