Skip to content
This repository has been archived by the owner on Nov 4, 2018. It is now read-only.

Commit

Permalink
Merge branch 'no-mime-magic-option' of git://github.com/radomirml/s3c…
Browse files Browse the repository at this point in the history
…md into merge
  • Loading branch information
mdomsch committed Nov 26, 2013
2 parents d9178db + b4207d9 commit acb85bf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions S3/Config.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion S3/S3.py
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions s3cmd
Expand Up @@ -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.")
Expand Down
3 changes: 3 additions & 0 deletions s3cmd.1
Expand Up @@ -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
Expand Down

0 comments on commit acb85bf

Please sign in to comment.