No release in over 3 years
Low commit activity in last 3 years
Refile backend that's based on `Refile::Backend::FileSystem` and stores files in sub-directories based on the given file id instead of storing all files on one directory.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.5
 Project Readme

Refile::Backend::FileSystemHashed

Refile backend that's based on Refile::Backend::FileSystem and stores files in sub-directories based on the given file id instead of storing all files on one directory.

Refile's out-of-the-box backend Refile::Backend::FileSystem stores all files within one directory which can get very large and makes maintenance (ls, etc.) very slow. This gem extends the default behavior, it splits up the directory in tiny chunks based on the given file id. For example if there is a file with id 0601ae4450cdc210ab9d05da50c392ee1c4b1894e8b2bc9cc5cc9e41e691 it stores the file in the nested directory 06/01/ae/44/0601ae4450cdc210ab9d05da50c392ee1c4b1894e8b2bc9cc5cc9e41e691 within the given directory.

Usage

Add refile-filesystem-hashed to your Gemfile.

gem 'refile-filesystem-hashed', '~> 1.0.1', require: 'refile/backend/file_system_hashed'

Replace Refile::Backend::FileSystem with Refile::Backend::FileSystemHashed.

backend = Refile::Backend::FileSystemHashed.new("/uploads")
backend.path('0601ae4450cdc210ab9d05da50c392ee1c4b1894e8b2bc9cc5cc9e41e691')
=> "/uploads/06/01/ae/44/0601ae4450cdc210ab9d05da50c392ee1c4b1894e8b2bc9cc5cc9e41e691"

You can replace Refile::Backend::FileSystem at any time as the gem will automagically move existing files to the new hashed directory structure.