Is it a problem to create a directory for every file upload in a web application on linux / unix?

I am doing a file upload for a web application (works on unix / linux). I am wondering if there will be a problem if I plan to create a new directory for every file upload? This is a ready-made approach for the Ruby on Rails "paperclip" plugin. I am discussing what the tradeoffs are or maybe it just isn't an issue if you are deploying in a linux / unix environment.

Possible options:

  • One folder for each file attachment - for how the paperclip seems to work out of the box.
  • Maybe there is one folder per user (i.e. if the web service has multiple users with their own account) and then some uniqueness needs to be added to the file name (model ID perhaps).
  • Put all attachments in one folder - but that's probably too far away.

Question. Should I be worried about the number of directories being created? Is it a problem for O / S if the service was popular? Any tips for a website that allows users with their own separate account to upload files, what structure might be good for storing them? (I assume I missed the concept of storing files in mysql.)

thank

+2


source to share


3 answers


Let's assume an Ext3 formatted disk under Linux (the most common).

From ( http://en.wikipedia.org/wiki/Ext3 )



"There is a limit of 31998 subdirectories per directory based on its limit of 32000 references per index. [13]"

So, if you hit the 32K download limit, which is not that high, your application will fail.

+5


source


If you have a separate section for a directory where new files / directories are created, I would say this is not a problem. This can be a problem if you are just using a different partition, as you can run from inodes and / or free disk space, which can be bad.



Using a separate partition (in case of a DOS attack) will only stop your application from working properly and the system will not be harmed in any way.

0


source


Not so, but having gazillions of folders in the same directory (or the same for files) is not recommended (this is a real hit to speed).

Reason: c-style lines

A good solution would be to hierarchically (sic?) Store something like: / path / to / usernamefirstletter / username / year / month / file

0


source







All Articles