Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support user-defined content-type header #16

Closed
wants to merge 3 commits into from

2 participants

@ghost

This fork enables commands such as

s3cmd --add-header "content-type: text/html; charset=utf-8" sync [SOURCE] s3://[BUCKET]

@mludvig
Owner

Hi,

thanks for the patch. However I took a different approach and modified the mime type parser to enable --mime-type="text/html; charset=utf-8". That's a more natural way for setting the charset rather than abusing --add-header for that.

My patch is in commit 615eed4.

@mludvig mludvig closed this
@ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 15, 2011
  1. @jarkkorantala
  2. Removed new line

    Tero Kaisti authored
  3. @jarkkorantala

    Merge pull request #1 from ternur/newlinefix

    jarkkorantala authored
    Removed new line
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 7 deletions.
  1. +8 −7 S3/S3.py
View
15 S3/S3.py
@@ -349,13 +349,14 @@ def object_put(self, filename, uri, extra_headers = None, extra_label = ""):
if extra_headers:
headers.update(extra_headers)
headers["content-length"] = size
- content_type = self.config.mime_type
- if not content_type and self.config.guess_mime_type:
- content_type = mime_magic(filename)
- if not content_type:
- content_type = self.config.default_mime_type
- debug("Content-Type set to '%s'" % content_type)
- headers["content-type"] = content_type
+ if not "content-type" in headers:
+ content_type = self.config.mime_type
+ if not content_type and self.config.guess_mime_type:
+ content_type = mime_magic(filename)
+ if not content_type:
+ content_type = self.config.default_mime_type
+ headers["content-type"] = content_type
+ debug("Content-Type set to '%s'" % content_type)
if self.config.acl_public:
headers["x-amz-acl"] = "public-read"
if self.config.reduced_redundancy:
Something went wrong with that request. Please try again.