Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'mime-guessing'

  • Loading branch information...
commit a845413126159a77b351dbb32f305be177bba6b2 2 parents 9447184 + 990b48c
Karsten Sperling ksperling authored
Showing with 10 additions and 3 deletions.
  1. +9 −2 S3/S3.py
  2. +1 −1  s3cmd
11 S3/S3.py
View
@@ -37,7 +37,14 @@ def mime_magic_file(file):
return magic_.from_file(file)
def mime_magic_buffer(buffer):
return magic_.from_buffer(buffer)
- except (TypeError, AttributeError):
+ except TypeError:
+ ## http://pypi.python.org/pypi/filemagic
+ magic_ = magic.Magic(flags=magic.MAGIC_MIME)
+ def mime_magic_file(file):
+ return magic_.id_filename(file)
+ def mime_magic_buffer(buffer):
+ return magic_.id_buffer(buffer)
+ except AttributeError:
## Older python-magic versions
magic_ = magic.open(magic.MAGIC_MIME)
magic_.load()
@@ -65,7 +72,7 @@ def mime_magic(file):
if (not magic_warned):
warning(magic_message)
magic_warned = True
- return mimetypes.guess_type(file)[0]
+ return mimetypes.guess_type(file)
__all__ = []
class S3Request(object):
2  s3cmd
View
@@ -1518,7 +1518,7 @@ def main():
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( "--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( "--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("-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("-m", "--mime-type", dest="mime_type", type="mimetype", metavar="MIME/TYPE", help="Force MIME-type. Override both --default-mime-type and --guess-mime-type.")
Please sign in to comment.
Something went wrong with that request. Please try again.