A Content-Type patch for Tim Kay's AWS Perl tool
--- /home/mikael/bin/aws.orig 2007-06-10 02:45:37.000000000 +0300
+++ /home/mikael/bin/aws 2007-07-10 04:12:31.000000000 +0300
@@ -500,7 +500,10 @@
}
}
- my $data = "$verb\n\n\n$expires\n/$name";
+ my($content_type) = `file -bi "$file"` if $isPUTobj;
+ chomp($content_type) if $isPUTobj;
+
+ my $data = "$verb\n\n$content_type\n$expires\n/$name";
my($sig, $awskey) = sign($data);
my $url = "https://s3.amazonaws.com/$name?AWSAccessKeyId=@{[encode_url($awskey)]}&Expires=$expires&Signature=@{[encode_url($sig)]}";
@@ -508,6 +511,8 @@
$content = "--upload-file @{[cq($file)]}" if $isPUTobj;
$content = "--output @{[cq($file)]}" if $verb eq GET && $file;
+ $content .= " --header 'Content-Type: $content_type' " if $content_type;
+
my $content_length = "--header 'Content-Length: $length'" if $length;
if ($isGETobj)Update: and here's the patch for a slightly more recent version. --- aws.tim 2007-08-19 23:03:08.000000000 +0300 +++ aws.gumi2 2007-09-01 17:32:42.000000000 +0300 @@ -517,13 +517,16 @@ } my $header = join("\n", map {s/^(.?):\s/\L$1:/s; $_} @header) . "\n" if @header; - my $data = "$verb\n\n\n$expires\n$header/$name"; + my($content_type) = $isPUTobj ? file -bi "$file" : ""; + chomp($content_type) if $content_type; + my $data = "$verb\n\n$content_type\n$expires\n$header/$name"; my($sig, $awskey) = sign($data); my $url = "https://s3.amazonaws.com/$name?AWSAccessKeyId=@{[encode_url($awskey)]}&Expires=$expires&Signature=@{[encode_url($sig)]}"; my($content); $content = "--upload-file @{[cq($file)]}" if $isPUTobj; $content = "--output @{[cq($file)]}" if $verb eq GET && $file; + $content .= " --header 'Content-Type: $content_type' " if $content_type; my $content_length = "--header 'Content-Length: $length'" if $length;