-
Notifications
You must be signed in to change notification settings - Fork 1.7k
How to: Store same file on same place, but different record
stvkoch edited this page Oct 8, 2012
·
1 revision
This plugin helps carrierwave(https://github.com/jnicklas/carrierwave) saving images/docs with same content on one place, even if you have different names. It was developed for the models that can save the same(same content) files but in different records, saving disk space.
Imagine:
item = Item.find(3)
item.id
//3
item.name
//Hard Disk 100Gb
item.image
//1234567_hex.jpg
item.image_url
//uploads/item/image/12/34/56/1234567_hex.jpg
otherItem = Item.find(5)
otherItem.id
//5
otherItem.name
//Hard Disk 120Gb
otherItem.update_attributes(:image=>'web_image_but_same_content.jpg')
otherItem.image
//1234567_hex.jpg
otherItem.image_url
//uploads/item/image/12/34/56/1234567_hex.jpg
these two records have different data, but with identical content files. CarrierWave::SingleStore holds one file for both records, saving space disk
See examples folder. https://github.com/stvkoch/carrierwave_single_store/tree/master/examples
https://github.com/jnicklas/carrierwave
rails plugin install git@github.com:stvkoch/carrierwave_single_store.git