我正在 S3 之上实现一个文件管理器,目前正在尝试通过 LifeCycles 实现无缝冰川归档。 LifeCycles 的 S3 方面非常简单。但是我找不到返回 key 的实际存储类的方法。它显然是可用的,因为 S3 控制面板显示了它。
在存储类的文档中,他们提到应该存在此元数据对象(S3 Using Metadata):
x-amz-storage-class Storage class used for storing the object.
headObject 文档提到它应该返回元数据,但是当我运行它时,没有返回元数据 block 。
Delete-Marker: "",
Accept-Ranges: "bytes",
Expiration: "",
Restore: "",
Last-Modified: "Mon, 08 Sep 2014 20:27:39 GMT",
Content-Length: "3976807",
ETag: "0359f81b950a395d3f4ee0bf****",
Missing-Meta: "",
Version-Id: "Mb96ZF0dm506eXP***",
Cache-Control: "",
Content-Disposition: "",
Content-Encoding: "",
Content-Language: "",
Content-Type: "video/x-ms-wmv",
Expires: "",
Website-Redirect-Location: "",
Server-Side-Encryption: "",
SSECustomerAlgorithm: "",
SSECustomerKeyMD5: "",
Request-Id: "43AD99D48F****E"
同时,文档声称元数据应该是返回的字段之一:
Metadata => (associative-array<string>)
Associative array of <string> keys mapping to (string) values. Each array key should be changed to an appropriate <string>.
A map of metadata to store with the object in S3.
<string> => (string)
The metadata value.
仅供引用,我正在使用此文档 AWS SDK for PHP
任何建议都值得赞赏,因为目前我发现的唯一解决方案是运行 getObject (这是不可行的,因为它将下载整个对象)或在每次调用时运行 RestoreObject 并检查其异常代码。但这意味着在不恢复 key 的情况下无法检查其状态(如果已存档)
谢谢。
最佳答案
我能够得到它。当我运行以下代码时:
$s3 = \Aws\S3\S3Client::factory($config);
$result = $s3->listObjects(array(
'Bucket' => 'somebucket'
));
echo $result;
我得到了这个输出,它包含 StorageClass:
[Name] => soembucket
[Prefix] => Array
(
)
[Marker] => Array
(
)
[MaxKeys] => 1000
[IsTruncated] =>
[Contents] => Array
(
[0] => Array
(
[Key] => e2014090520140911a.jpg
[LastModified] => 2014-09-04T21:06:49.000Z
[ETag] => "7ae0adc21a443ab8d4499cabaa54157b"
[Size] => 101961
[Owner] => Array
(
[ID] => 8c1a9525cee6d6caa294e524b4bb1d28481e53473cc48a26e714e89665cb7afc
[DisplayName] => amazon_aws
)
[StorageClass] => STANDARD
)
[1] => Array
(
[Key] => e2014091220141002a.jpg
[LastModified] => 2014-09-11T21:19:33.000Z
[ETag] => "96882d755e7864bd01d75cb24673fb00"
[Size] => 219311
[Owner] => Array
(
[ID] => 8c1a9525cee6d6caa294e524b4bb1d28481e53473cc48a26e714e89665cb7afc
[DisplayName] => amazon_aws
)
[StorageClass] => STANDARD
)
)
[EncodingType] =>
[RequestId] => 30BB77F212066343
关于php - 使用AWS SDK查询存储类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25858771/