2018-07-04 13:32:46 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-06 06:36:11 -05:00
|
|
|
class NamespaceFileUploader < FileUploader
|
2018-02-02 08:59:43 -05:00
|
|
|
# Re-Override
|
|
|
|
def self.root
|
|
|
|
options.storage_path
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|
|
|
|
|
2018-03-02 10:41:40 -05:00
|
|
|
def self.base_dir(model, _store = nil)
|
2018-02-02 08:59:43 -05:00
|
|
|
File.join(options.base_dir, 'namespace', model_path_segment(model))
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
def self.model_path_segment(model)
|
|
|
|
File.join(model.id.to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Re-Override
|
|
|
|
def store_dir
|
|
|
|
store_dirs[object_store]
|
|
|
|
end
|
2017-12-06 06:36:11 -05:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
def store_dirs
|
|
|
|
{
|
|
|
|
Store::LOCAL => File.join(base_dir, dynamic_segment),
|
2018-03-02 10:41:40 -05:00
|
|
|
Store::REMOTE => File.join('namespace', self.class.model_path_segment(model), dynamic_segment)
|
2018-02-02 08:59:43 -05:00
|
|
|
}
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|
|
|
|
end
|