[s3-dev] AWS::S3::SignatureDoesNotMatch error when content-type can't be inferred
Marcel Molina Jr.
marcel at vernix.org
Thu Dec 14 17:59:25 EST 2006
On Wed, Dec 13, 2006 at 02:14:06PM -0500, Stephen Caudill wrote:
> Down to bidness. When AWS::S3 fails to infer the content-type (odd
> file extension, no file extension), it throws an
> AWS::S3::SignatureDoesNotMatch error, which is misleading. I've
> gotten the same results from both 0.2.1 and latest trunk.
>
> here's a script that demonstrates it:
>
> [02:05:58][caudill at lazuli][Desktop]$ cat aws-script-helper-test.rb
> require 'rubygems'
> require 'aws/s3'
> include AWS::S3
>
> Base.establish_connection!(
> :access_key_id => 'foo',
> :secret_access_key => 'bar'
> )
>
> Bucket.create('buckets-r-teh-niftyest')
>
> S3Object.store('s3sh', File.open('/usr/local/bin/s3sh'), 'buckets-r-
> teh-niftyest')
> %
>
> Here's the error, as reported by RubyMate:
>
> AWS::S3::SignatureDoesNotMatch: The request signature we calculated
> does not match the signature you provided. Check your key and signing
> method.
Hey Stephen, thanks for reporting this.
Someone brought this up a few weeks ago (http://developer.amazonwebservices.com/connect/message.jspa?messageID=49153#49156) and at the time I couldn't recreate
it. I still can't recreate it actually, which is weird:
>> S3Object.store('s3sh', File.open('/opt/local/bin/s3sh'), 'marcel')
=> #<AWS::S3::S3Object::Response:0x10993930 200 OK>
This is the patch that David Hanson proposed:
Index: lib/aws/s3/object.rb
===================================================================
--- lib/aws/s3/object.rb (revision 142)
+++ lib/aws/s3/object.rb (working copy)
@@ -302,6 +302,8 @@
return if options.has_key?(:content_type)
if mime_type = MIME::Types.type_for(key).first
options[:content_type] = mime_type.content_type
+ else
+ options[:content_type] = 'binary/octet-stream'
end
end
end
Since I can't reproduce the problem, I don't know if that fixes it though it
seems to have worked for him. Unfortunately that breaks other behavior. It
makes it so you can't explicitly set a content type on an instance of an
S3Object. The fix so that both live happily ever after probably isn't that
tough. I plan on looking into the specifics and working up a fix soon.
Thanks again for the report and sorry for the lag time in responding (I was
withouth internet yesterday),
marcel
--
Marcel Molina Jr. <marcel at vernix.org>
More information about the amazon-s3-dev
mailing list