s3tools/s3cmd — pull request #228 by mdanilescu (2013-10-02 09:21:44+00:00)
Title: Custom headers support based on regex match on filenames

I did some updates:

1. Added new option (--add-headers-from) which allows adding custom headers during sync with S3 based on a yaml file input. The regex match is done on filenames.

E.g.:
$ cat headers.conf
'.*.js$': ['cache-control:max-age=2592000', 'content-type:text/javascript; charset=UTF-8']
'.*css$': ['content-type:text/css; charset=UTF-8', 'cache-control:max-age=2592000']
'.*js.gz$': ['content-type:text/javascript; charset=UTF-8', 'cache-control:max-age=2592000', 'content-encoding:gzip']
'.*css.gz$': ['content-type:text/css; charset=UTF-8', 'cache-control:max-age=2592000', 'content-encoding:gzip']

2. 'content-type' header can be easily overwritten (most of the times the mime_type was completely wrong).

3. Took the header processing code and put it in a function (to use it for the new custom headers as well).