Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding id_partition in Paperclip

I'm using Paperclip to store audio files in AWS.

The files path has an id_partition component (spanning 3 directories).

How does this field is calculated?

I want to be able to track the file from my rails module (or DB entry)

Thank you

like image 418
kambi Avatar asked Mar 19 '13 08:03

kambi


1 Answers

paperclip id_partition method prepend '0' to ID of ActiveRecord instance to make it of length 9 characters.

i.e 12 would be converted to 000000012, then it simply splits this string into three chunks and joins these chunks with /

interesting reads on id_partition http://37signals.com/svn/archives2/id_partitioning.php

like image 142
Naveed Avatar answered Sep 23 '22 00:09

Naveed