namespace_file_uploader.rb 694 Bytes
Newer Older
1 2
# frozen_string_literal: true

3
class NamespaceFileUploader < FileUploader
4 5 6
  # Re-Override
  def self.root
    options.storage_path
7 8
  end

9 10 11 12 13 14 15 16 17
  def self.base_dir(model, store = nil)
    base_dirs(model)[store || Store::LOCAL]
  end

  def self.base_dirs(model)
    {
      Store::LOCAL => File.join(options.base_dir, 'namespace', model_path_segment(model)),
      Store::REMOTE => File.join('namespace', model_path_segment(model))
    }
18 19
  end

20 21 22 23
  def self.model_path_segment(model)
    File.join(model.id.to_s)
  end

24 25 26 27
  def self.workhorse_local_upload_path
    File.join(options.storage_path, 'uploads', TMP_UPLOAD_PATH)
  end

28 29 30 31
  # Re-Override
  def store_dir
    store_dirs[object_store]
  end
32
end