Partitioning the file storage/dynamic portion of :path attribute

14 views
Skip to first unread message

Christopher Bailey

unread,
Sep 25, 2008, 5:44:36 PM9/25/08
to papercli...@googlegroups.com
We use the filesystem for storage of our Paperclip attachments.  I'm thinking about how this scales in terms of the directory naming scheme, etc. for these attachments.  If I set the :path attribute to something like:

/data/assets/:class/:attachment/:id/:style.:extension

then, as the records for that class grow, we'll start getting a lot of directories within the directory where it is named by ID.  I'm wondering what folks have used done in order to partition this so that you don't wind up with say tens of thousands or hundreds of thousands, or more subdirectories within a single directory?  Are you just putting a dynamic calculation into that or?  Other approaches?

--
Christopher Bailey
Cobalt Edge LLC
http://cobaltedge.com

Chad Pytel

unread,
Sep 25, 2008, 6:02:33 PM9/25/08
to papercli...@googlegroups.com
Paperclip supports using a directory structure that is a partition of the model id out of the box using the :id_partition interpolation. This should solve any reasonable concerns about directory content limits.

thanks,
-Chad



---
Chad Pytel, Founder and CEO
thoughtbot, inc.
organic brains. digital solutions.
-------------------------------------------




Christopher Bailey

unread,
Sep 26, 2008, 1:18:07 PM9/26/08
to papercli...@googlegroups.com
Wow, that rocks, thank you!
Reply all
Reply to author
Forward
0 new messages