MCPcopy Create free account
hub / github.com/s3tools/s3cmd / content_type

Method content_type

S3/S3.py:709–728  ·  view source on GitHub ↗
(self, filename=None, is_dir=False)

Source from the content-addressed store, hash-verified

707 return content_type
708
709 def content_type(self, filename=None, is_dir=False):
710 # explicit command line argument always wins
711 content_type = self.config.mime_type
712 content_charset = None
713
714 if filename == u'-':
715 return self.stdin_content_type()
716
717 if is_dir:
718 content_type = 'application/x-directory'
719 elif not content_type:
720 (content_type, content_charset) = self._guess_content_type(filename)
721
722 ## add charset to content type
723 if not content_charset:
724 content_charset = self.config.encoding.upper()
725 if self.add_encoding(filename, content_type) and content_charset is not None:
726 content_type = content_type + "; charset=" + content_charset
727
728 return content_type
729
730 def add_encoding(self, filename, content_type):
731 if 'charset=' in content_type:

Callers 1

object_putMethod · 0.95

Calls 3

stdin_content_typeMethod · 0.95
_guess_content_typeMethod · 0.95
add_encodingMethod · 0.95

Tested by

no test coverage detected