Attachement_fu physical storage structure

Hi -

Can someone explain how/why attachment_fu stores its files the way it does? I noticed that it creates a directory for each upload and am curious how it determines this and/or the methodology.

Thanks!

It creates a directory for each model you define with “has_attachment” within the public folder (although you can change the storage path if you want to). Then it creates partitioned folders by default based on the id of your model record (this can disabled if you want to). For record with id=1 in your Document model, it will create documents/0000/0001/file.ext. The reason why it partitions the folders has to do with filesystem limits iirc. Some storage systems have a limit to the number of folders within a directory.

The best thing to do, is just browse through the source code (or rdoc) of the plugin yourself, it’s well documented and tells you all you need to know.

Best regards

Peter De Berdt

Thank you - this makes sense and re-assures some speculations.

Peter De Berdt wrote: