Publish script should set content-type

f2bfbd69277c92ee8abbaf1832e7869b991683d7
Alexis Sellier committed ago 1 parent 39c49479
publish +4 -1
1 1
#!/usr/bin/env ruby
2 2
3 3
require 'aws-sdk-v1'
4 4
require 'digest/md5'
5 +
require 'rack/mime'
5 6
6 7
SITE = AWS::S3.new(region: ENV['AWS_REGION'] || 'eu-west-1')
7 8
              .buckets[File.basename(Dir.pwd)]
8 9
9 10
USAGE = <<EOF
28 29
    remote_md5 = obj.etag.tr('"', '') if obj.exists?
29 30
30 31
    print "#{f}.. "
31 32
32 33
    if local_md5.to_s != remote_md5.to_s
33 -
      obj.write(Pathname.new(f))
34 +
      obj.write(Pathname.new(f),
35 +
                :content_type => Rack::Mime::MIME_TYPES[File.extname(f)])
34 36
      obj.acl = :public_read
37 +
35 38
      puts "ok"
36 39
    else
37 40
      puts "skipping"
38 41
    end
39 42
  end