views:

94

answers:

3

37 signals suggests id partitioning to accomplish this thing..

http://37signals.com/svn/archives2/id%5Fpartitioning.php

Any suggestions would be more than welcome.

Thanks.

+1  A: 

We use partitioning by date so an image uploaded today would end up in 2009/12/10/image_12345.jpg. The path is stored in the db for reference and the path to the image folder (the parent of 2009) is placed in some config file. If we need to change things later it makes it very easy.

Emil Ivanov
A: 

You can map by virtually everything. We use mapping by user on our designs, but it's a HR system so it makes sense (there's no way the user will have 32k file entries) and the files are clearly connected with user. On Media Library parts of the system dividing by date or ID will be more useful.

The catch is, you should store some part of file path in database table (as suggested before). Will it be date, or user hash/name (often also divided, eg u/user j/john j/jo/john etc). Then you don't have to worry about changing division system, as this will only require database update.

Tomasz Struczyński
+4  A: 

We use Paperclip for storing our files. It can do what you want pretty easily.

egarcia