Sha256: 12122f19ad232e33169d09d8801e19db028a894171c03b672bdf8ef0a2af2987

Contents?: true

Size: 1.35 KB

Versions: 13

Compression:

Stored size: 1.35 KB

Contents

require 'carrierwave'

# 日本語ファイル名のまま保存
CARRIERWAVE_SANITIZE_REGEXP = /[^[:word:]①-⑨【】「」()・&、  \(\)\.\-\+]/
CarrierWave::SanitizedFile.sanitize_regexp = CARRIERWAVE_SANITIZE_REGEXP

module Bizside
  class CarrierwaveStringIO < StringIO
    attr_accessor :original_filename
    attr_accessor :content_type
    attr_accessor :file_size

    def path
      original_filename
    end
  end
end

unless Bizside.config.within_bizside_namespace?
  # 後方互換性の維持
  CarrierwaveStringIO = Bizside::CarrierwaveStringIO
end

CarrierWave.configure do |config|
  database_yml = ERB.new(File.read(File.join('config', 'database.yml')), 0, '-').result
  database = YAML.load(database_yml)[Bizside.env]['database']

  config.root = File.join('/data', Bizside.config.add_on_name, database)

  if Bizside.config.storage.fog?
    require 'carrierwave/storage/fog'
    require 'fog/aws'

    # fog の場合は、相対パス
    config.root = config.root[1..-1]

    credentials = Bizside.config.storage.fog.credentials.to_h.symbolize_keys
    if credentials[:use_iam_profile]
      credentials = credentials.merge(role_session_name: Bizside.config.add_on_name)
    end
    config.fog_credentials = credentials

    config.fog_directory = Bizside.config.storage.fog.container
    config.fog_public = false
    config.storage = :fog
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bizside-2.1.3 lib/bizside/carrierwave.rb
bizside-2.1.2 lib/bizside/carrierwave.rb
bizside-2.1.1 lib/bizside/carrierwave.rb
bizside-2.1.0 lib/bizside/carrierwave.rb
bizside-2.0.9 lib/bizside/carrierwave.rb
bizside-2.0.8 lib/bizside/carrierwave.rb
bizside-2.0.7 lib/bizside/carrierwave.rb
bizside-2.0.6 lib/bizside/carrierwave.rb
bizside-2.0.5 lib/bizside/carrierwave.rb
bizside-2.0.4 lib/bizside/carrierwave.rb
bizside-2.0.3 lib/bizside/carrierwave.rb
bizside-2.0.2 lib/bizside/carrierwave.rb
bizside-2.0.1 lib/bizside/carrierwave.rb