Class: StaticSync::Meta
- Inherits:
-
Object
- Object
- StaticSync::Meta
- Defined in:
- lib/static_sync/meta.rb,
lib/static_sync/meta/caching.rb,
lib/static_sync/meta/compression.rb
Defined Under Namespace
Classes: Caching, Compression
Instance Method Summary collapse
- #for(file) ⇒ Object
-
#initialize(config) ⇒ Meta
constructor
A new instance of Meta.
Constructor Details
#initialize(config) ⇒ Meta
Returns a new instance of Meta.
10 11 12 13 14 |
# File 'lib/static_sync/meta.rb', line 10 def initialize(config) @config = config @compression = Compression.new(@config) @caching = Caching.new(@config) end |
Instance Method Details
#for(file) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/static_sync/meta.rb', line 16 def for(file) = { :key => file, :body => File.new(file), :public => true, :storage_class => 'REDUCED_REDUNDANCY' } mime = MIME::Types::of(file).first if mime .merge!( :content_type => MIME::Type.simplified(mime) ) .merge!(@compression.for(file, mime)) .merge!(@caching.for(file, mime)) end body = [:body].read .merge!( :etag => Digest::MD5.hexdigest(body), # A local version of the etag expected after upload. :content_md5 => Digest::MD5.base64digest(body) # Enable checksum validation during uploads. ) end |