Wondering Coder
Wondering Coder

Reputation: 1702

Signature does not match s3 uploading object

I'm trying to implement an unploading of image to amazon s3 using only rest api. I've seen their docs but the problem is I'm only using temporary credential which will expire for about an hour. Below is the response

{
 accessKey: "mykey"
 secretKey: "mysecret"
 token: "mytemptoken"
 expiry: 1381128021000
}

My policy

POLICY_JSON = { "expiration": "2013-12-03T12:29:27.000Z",
            "conditions": [
                    ["eq", "$bucket", this.get('bucket')],
                    ["starts-with", "$key", this.get('key')],
                    {"acl": this.get('acl')},
                    {"success_action_redirect": this.get('successActionRedirect')},
                    ["starts-with", "$Content-Type", this.get('contentType')]
            ]
          };

Here what I tried so far: Using chrome advance rest client I entered this url: https://mybucket.s3.amazonaws.com/avatars/[email protected] with headers of

Authorization: AWS mykey:CXp5qqO6q552VDYUI0aBlSd/pTs=
x-amz-security-token: mytemptoken
x-amz-date: Mon, 07 OCt 2013 06:20:37 GMT

The result was: 403 Forbidden and its saying SignatureDoesNotMatch. Does anyone able to accomplish uploading of object using only Rest Api of s3 (not using of SDK's). The client asked me if its possible to build it using only javascript. Is this possible?

Upvotes: 0

Views: 3668

Answers (1)

Satish
Satish

Reputation: 711

Should you not sign the content? Check this how to sign. After signing you have to pass the signature value in the Authorization header.

Authorization: AWS AWSAccessKeyId:Signature

Upvotes: 1

Related Questions