Sha256: aa73453f0e01a30b630550c424b023468c6a2a0bfb67e2865b5e9fb595f154fa
Contents?: true
Size: 1.49 KB
Versions: 4
Compression:
Stored size: 1.49 KB
Contents
# encoding: UTF-8 # storage :s3 do |config| # config[:provider] = "AWS", # config[:aws_access_key_id] = "key", # config[:aws_secret_access_key] = "secret", # config[:region] = 'eu-west-1' # config[:bucket] => "name_of_bucket" # config[:accepts] => "image/*" # end # storage :another_local do |config| # config.update({ # :provider => "Local" # }) # end class Spontaneous::Site module Storage extend Spontaneous::Concern module ClassMethods def storage(mimetype = nil) instance.storage(mimetype) end def local_storage instance.local_storage end def default_storage instance.default_storage end end # ClassMethods def storage(mimetype = nil) storage_for_mimetype(mimetype) end def storage_for_mimetype(mimetype) storage_backends.detect { |storage| storage.accepts?(mimetype) } end def local_storage storage_backends.select { |storage| storage.local? } end def storage_backends @storage_backends ||= configure_storage end def configure_storage storage_backends = [] storage_settings = config[:storage] || [] storage_settings.each do |name, config| backend = Spontaneous::Storage.create(config) storage_backends << backend end storage_backends << default_storage end def default_storage @default_storage ||= Spontaneous::Storage::Local.new(Spontaneous.media_dir, '/media', accepts=nil) end end end
Version data entries
4 entries across 4 versions & 1 rubygems