I would save user images. However, given that you have potentially many users, this may not be so simple.
Downloading user files is only: downloading files specific to the user. When you manage these files, you often have to apply different procedures for each user. For example: 1) delete the user account and delete all related files, 2) calculate the amount of space that the user uses, 3) list all the files that the user has uploaded, etc.
If you distribute these files in different directories, it is much more difficult to efficiently perform the above procedures.
You indicated that you may have more than 100,000 users. Depending on your file system, this may cause you problems. For example, ext3 has a maximum of 32K subdirectories for a directory, which can be a problem for organizing files in directories for each user (see How many files can be placed in a directory? ).
Assuming we cannot store more than 32K files or directories inside a directory, you will need to find a way around this limit. For example, you can divide user folders into several subdirectories according to the first letter in the username (and add an additional subdirectory for all other start characters):
users a aaron ... b bertie ... ... misc _foobar ... @jack ...
Now you have only approximately 100000/25=4000 users in the directory that is under this 32K.
Thinking outside the box may be the wrong choice for storing images as files on a flat file system. There are database systems that are specifically designed to store and process a large number of files. Take MongoDB GridFS, for example . It is very efficient and scalable for a large number of files, and also takes care of all the problems of a lower level, such as the proper use of the file system. In MS SQL, there is a FILESTREAM> repository that stores files especially well in the NTFS file system.
source share