Class: Bizside::FileUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
Uploader::ContentTypeValidator, Uploader::ExtensionWhitelist, Uploader::FilenameValidator
Defined in:
lib/bizside/file_uploader.rb

Overview

storage.yml

storage.yml に fog エントリが定義されている場合、fog 参照先 のストレージの fog.container に保存します。

storage.yml が存在しない・又は fog エントリがない場合はローカルに保存します。

Instance Method Summary collapse

Methods included from Uploader::ContentTypeValidator

#content_type_checklist

Methods included from Uploader::FilenameValidator

#invalid_filename_regexp

Methods included from Uploader::ExtensionWhitelist

#extension_allowlist

Instance Method Details

#cache!(new_file = sanitized_file) ⇒ Object

ファイル名の長さチェックが可能なように



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bizside/file_uploader.rb', line 44

def cache!(new_file = sanitized_file)
  begin
    super
  rescue Errno::ENAMETOOLONG => e
    if Bizside.config.file_uploader.ignore_long_filename_error?
      if self.model.respond_to?(:original_filename)
        self.model.original_filename = filename
      end
    else
      raise e
    end
  end
end

#downloaded_fileObject



39
40
41
# File 'lib/bizside/file_uploader.rb', line 39

def downloaded_file
  Bizside.config.storage.fog? ? downloaded_file_from_fog(file.path) : file.path
end