fredjean / middleman-s3_sync

The gem that tries really hard not to push files to S3.
MIT License
271 stars 75 forks source link

Setting content-type isn't working #134

Open csimmons0 opened 7 years ago

csimmons0 commented 7 years ago

I've been unable to set files' content-type. Is this a known issue? I tried debugging it by putting some print statements inside of the "def content_type" statement in resource.rb, and it looked like the Middleman::S3Sync::content_types dictionary was completely empty no matter what I put in s3_sync.content_types in config.rb. It also looked like the local_path variable used as a key to that dictionary had values other than what I expected. Instead of "index.html," for example, its value would be "build/index.html."

cpence commented 6 years ago

+1 to this for me, too. I think that Middleman::S3Sync::content_types is an error; it should be options.content_types?

cpence commented 6 years ago

I can monkey-patch this to work by adding:

module Middleman::S3Sync
  def self.content_types
    {
      'build/travel/data.geojson' => 'application/json'
    }
  end
end

to the config file, if that helps anybody else who finds this bug (where build/ is my build directory). But that's definitely not how this feature is supposed to work!

ndorfin commented 6 years ago

I've issued a PR (to address this issue) that could do with some help. See: https://github.com/fredjean/middleman-s3_sync/pull/153