我在S3之上实施了一个文件管理器,我目前正试图通过LifeCycles实现无缝冰川存档。 LifeCycles的S3方面非常直接。但是,我找不到一个方法,它将返回密钥的实际存储类。它显然可用,因为S3控制面板显示它。
在存储类的文档中,他们提到应该存在这个元数据对象(S3 Using Metadata):
x-amz-storage-class用于存储对象的存储类。
headObject文档提到它应该返回元数据,但是当我运行它时,不会返回元数据块。
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并检查其异常代码。但这意味着,如果不恢复密钥的状态,就无法检查密钥的状态(如果已归档)
谢谢。
答案 0 :(得分:2)
我能够得到它。当我运行以下代码时:
$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