octopress / deploy

Deployment for Octopress and Jekyll blogs.
MIT License
75 stars 23 forks source link

Support for adding headers to S3 files? #24

Closed awinder closed 10 years ago

awinder commented 10 years ago

I'm not sure if this is something you'd want to not tackle in this plugin at all, or something you'd want in a separate plugin, or something you think would make a good addition to the deploy module. But just in case it's the last one, I'd like to be able to set up some kind of configuration for adding sets of HTTP headers to my site files:

I'd definitely be willing to help out with coding on this, but I'm not even really sure what a sane configuration for this would look like. Hopefully this gives you at least some idea of what I'd be looking for here.

imathis commented 10 years ago

That's an interesting idea. It certainly seems like it would be useful. I don't have much experience with S3 and most of the work I've done with it was simply trying to figure out how to work with the S3 SDK. DO you know if the SDK has any support for this? Can you give me an idea of what you'd need to do (even manually) to add headers? Thanks!

awinder commented 10 years ago

http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/S3Object.html#write-instance_method allows for passing an options hash that sets the expires, content_type header, content_encoding, and cache_control headers, so it should be easy to set the options on the S3 uploads.

awinder commented 10 years ago

On second thought, I might be able to just code this out if this approach seems rational. What if the deploy module looked in the yaml configuration for a "headers" array, and the headers array contained objects with keys:

[
  {
     filepath: [string or regular expression],
     expires: [String],
     content-type: [String],
     content-encoding: [String],
     cache-control: [String]
  },
  ...
]

Then in the write_files method for S3, it iterates over the "headers" array, and runs each file path against the string or regex from the filepath key and tests for a match. If it hits a match, it adds all the other keys as options to the AWS library's write call. Does that sound sane?

imathis commented 10 years ago

This seems like the most rational path forward. It's certainly the most configurable.

awinder commented 10 years ago

I'll reopen as a pull request when I'm done, thanks for vetting that approach