Permalink
Browse files

* Force MIME type with --mime-type=abc/xyz

Option --mime-type now has a different meaning - from now on
it forces setting the given MIME type instead of setting a default
MIME type. For changing the default from binary/octet-stream use
a new option --default-mime-type.
Also --guess-mime-type is no longer on by default and if set to true
in the config file can be turned back off with --no-guess-mime-type
  • Loading branch information...
1 parent bcb4442 commit 35612e6183a1bc49df007c36ceece01aed5ad151 @mludvig mludvig committed Sep 22, 2011
Showing with 10 additions and 5 deletions.
  1. +2 −0 NEWS
  2. +2 −1 S3/Config.py
  3. +2 −2 S3/S3.py
  4. +4 −2 s3cmd
View
2 NEWS
@@ -4,6 +4,8 @@ s3cmd 1.1.0 - ???
* Increased socket_timeout from 10 secs to 5 mins.
* Added "Static WebSite" support [ws-create / ws-delete / ws-info]
(contributed by Jens Braeuer)
+* Force MIME type with --mime-type=abc/xyz, also --guess-mime-type
+ is no longer on by default.
s3cmd 1.0.0 - 2011-01-18
===========
View
@@ -60,7 +60,8 @@ class Config(object):
use_https = False
bucket_location = "US"
default_mime_type = "binary/octet-stream"
- guess_mime_type = True
+ guess_mime_type = False
+ mime_type = ""
# List of checks to be performed for 'sync'
sync_checks = ['size', 'md5'] # 'weak-timestamp'
# List of compiled REGEXPs
View
@@ -326,8 +326,8 @@ def object_put(self, filename, uri, extra_headers = None, extra_label = ""):
if extra_headers:
headers.update(extra_headers)
headers["content-length"] = size
- content_type = None
- if self.config.guess_mime_type:
+ content_type = self.config.mime_type
+ if not content_type and self.config.guess_mime_type:
content_type = mimetypes.guess_type(filename)[0]
if not content_type:
content_type = self.config.default_mime_type
View
6 s3cmd
@@ -1497,8 +1497,10 @@ def main():
optparser.add_option( "--access-logging-target-prefix", dest="log_target_prefix", help="Target prefix for access logs (S3 URI) (for [cfmodify] and [accesslog] commands)")
optparser.add_option( "--no-access-logging", dest="log_target_prefix", action="store_false", help="Disable access logging (for [cfmodify] and [accesslog] commands)")
- optparser.add_option("-m", "--mime-type", dest="default_mime_type", type="mimetype", metavar="MIME/TYPE", help="Default MIME-type to be set for objects stored.")
- optparser.add_option("-M", "--guess-mime-type", dest="guess_mime_type", action="store_true", help="Guess MIME-type of files by their extension. Falls back to default MIME-Type as specified by --mime-type option")
+ optparser.add_option( "--default-mime-type", dest="default_mime_type", action="store_true", help="Default MIME-type for stored objects. Application default is binary/octet-stream.")
+ optparser.add_option("-M", "--guess-mime-type", dest="guess_mime_type", action="store_true", help="Guess MIME-type of files by their extension. Fall back to default MIME-Type as specified by --default-mime-type option")
+ optparser.add_option( "--no-guess-mime-type", dest="guess_mime_type", action="store_false", help="Don't guess MIME-type and use the default type instead.")
+ optparser.add_option("-m", "--mime-type", dest="mime_type", type="mimetype", metavar="MIME/TYPE", help="Force MIME-type. Override both --default-mime-type and --guess-mime-type.")
optparser.add_option( "--add-header", dest="add_header", action="append", metavar="NAME:VALUE", help="Add a given HTTP header to the upload request. Can be used multiple times. For instance set 'Expires' or 'Cache-Control' headers (or both) using this options if you like.")

0 comments on commit 35612e6

Please sign in to comment.