diff --git a/S3/Config.py b/S3/Config.py index a68c44b2e..c8dc99a52 100644 --- a/S3/Config.py +++ b/S3/Config.py @@ -78,6 +78,7 @@ class Config(object): bucket_location = "US" default_mime_type = "binary/octet-stream" guess_mime_type = True + use_mime_magic = True mime_type = "" enable_multipart = True multipart_chunk_size_mb = 15 # MB diff --git a/S3/S3.py b/S3/S3.py index 1387c4c6e..8a28405c6 100644 --- a/S3/S3.py +++ b/S3/S3.py @@ -412,7 +412,7 @@ def object_put(self, filename, uri, extra_headers = None, extra_label = ""): content_type = self.config.mime_type content_encoding = None if filename != "-" and not content_type and self.config.guess_mime_type: - (content_type, content_encoding) = mime_magic(filename) + (content_type, content_encoding) = mime_magic(filename) if self.config.use_mime_magic else mimetypes.guess_type(filename) if not content_type: content_type = self.config.default_mime_type diff --git a/s3cmd b/s3cmd index b25b13466..477961638 100755 --- a/s3cmd +++ b/s3cmd @@ -1945,6 +1945,7 @@ def main(): 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 or mime magic. 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( "--no-mime-magic", dest="use_mime_magic", action="store_false", help="Don't use mime magic when guessing MIME-type.") 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.") diff --git a/s3cmd.1 b/s3cmd.1 index 2a18781b5..9e464fa4a 100644 --- a/s3cmd.1 +++ b/s3cmd.1 @@ -253,6 +253,9 @@ Guess MIME-type of files by their extension or mime magic. Fall back to default \fB\-\-no\-guess\-mime\-type\fR Don't guess MIME-type and use the default type instead. .TP +\fB\-\-no\-mime\-magic\fR +Don't use mime magic when guessing MIME-type. +.TP \fB\-m\fR MIME/TYPE, \fB\-\-mime\-type\fR=MIME/TYPE Force MIME-type. Override both \fB\-\-default\-mime\-type\fR and \fB\-\-guess\-mime\-type\fR. .TP