By default, an S3 List Objects (Get Bucket) query returns 1000 keys. According to the S3 documentation, if I want to list more objects, then I have to pass the marker query string along with my query when the marker value is set by the last key from the previous list of objects.
For some reason, this does not work for me ... It seems that I am missing something, and I am trying to figure out that.
Here's what the REST request should look like:
GET ?marker=LAST-KEY HTTP/1.1 Host: quotes.s3.amazonaws.com Date: Wed, 01 Mar 2009 12:00:00 GMT Authorization: AWS ACCESS_KEY_ID:SIGNATURE
My PHP code looks something like this:
... // this is where I'm getting the value of the last key $marker=$arrObjects["Contents"][999]["Key"]; ... //this is where I'm signing my request $canonicalizedResources = "/".$bucketName."/".(($marker=="")?"":"?marker=".rawurlencode($marker)); // $contentMD5 and $contentType are both empty strings "" $stringToSign = utf8_encode("GET"."\n".$contentMD5."\n".$contentType."\n".$timestamp."\n".$canonicalizedAmzHeaders.$canonicalizedResources); $signature = base64_encode(hash_hmac("sha1",$stringToSign,$customerSecretKey,true)); ...
This code works fine if I list objects in a bucket whose number is less than 1000. But whenever I pass a token to the request, I get a "Signature does not match" error.
Does anyone know where I am going wrong?
source share