【发布时间】:2011-07-20 00:08:07
【问题描述】:
默认情况下,S3 List Objects (Get Bucket) 请求会返回 1000 个键。根据 S3 文档,如果我想列出更多对象,那么我必须将标记查询字符串与我的请求一起传递,并将标记的值设置为上一个对象列表中的最后一个键。
由于某种原因,这对我不起作用......我似乎遗漏了一些明显的东西,我正在尝试找出什么。
这就是 REST 请求的样子:
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
我的 PHP 代码如下所示:
...
// 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));
...
如果我在存储桶中列出数量小于 1000 的对象,此代码可以完美运行。但每当我将标记传递给请求时,我都会收到“签名不匹配”错误。
有人知道我哪里出错了吗?
【问题讨论】:
-
为什么,哦,为什么不直接使用SDK?
-
因为 SDK 不支持 devpay s3 存储桶