lib/datapimp/sync/s3_bucket.rb in datapimp-1.0.13 vs lib/datapimp/sync/s3_bucket.rb in datapimp-1.0.14
- old
+ new
@@ -71,10 +71,11 @@
def asset_fingerprints
deploy_manifest['asset_fingerprints'] ||= {}
end
def run_push_action(options={})
+ require 'rack' unless defined?(::Rack)
entries = Dir[local_path.join('**/*')].map(&:to_pathname)
prepare_manifest_for(entries)
entries.reject! { |entry| entry.to_s.match(/\.DS_Store/) }
entries.reject!(&:directory?)
@@ -88,22 +89,25 @@
if asset_fingerprints[destination] == fingerprint
#log "Skipping #{ destination }: found in manifest"
next
end
+ content_type = Rack::Mime.mime_type(File.extname(destination.split("/").last))
+
if existing = s3.files.get(destination)
if existing.etag == fingerprint
log "Skipping #{ destination }: similar etag"
else
existing.body = entry.read
existing.acl = 'public-read'
- log "Updated #{ destination }"
+ existing.content_type = content_type
+ log "Updated #{ destination }; content-type: #{ content_type }"
uploaded << destination
existing.save
end
else
- log "Uploaded #{ destination }"
- s3.files.create(key: destination, body: entry.read, acl: 'public-read')
+ log "Uploaded #{ destination }; content-type: #{ content_type }"
+ s3.files.create(key: destination, body: entry.read, acl: 'public-read', content_type: content_type)
uploaded << destination
end
asset_fingerprints[destination] = fingerprint
end