使用AWS SDK查询存储类


Querying Storage Class with AWS SDK

我正在S3之上实现一个文件管理器,目前我正在尝试通过LifeCycles实现无缝冰川归档。LifeCycles的S3方面是非常直接的。但是,我找不到一个方法来返回密钥的实际存储类。它显然是可用的,因为S3控制面板显示了它

在存储类的文档中,他们提到应该存在此元数据对象(S3使用元数据):

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.

仅供参考,我正在使用此文档用于PHP 的AWS SDK

任何建议都值得赞赏,因为目前我找到的唯一解决方案是要么运行getObject(这是不可行的,因为它会下载整个对象),要么在每次调用时运行restoreObject并检查其异常代码。但这意味着,在不恢复密钥(如果已存档)的情况下,不可能检查密钥的状态

谢谢。

我能够得到它。当我运行以下代码时:

$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