2

我正在 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 应该是返回的字段之一:

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 并检查其异常代码。但这意味着在不恢复密钥的情况下无法检查密钥的状态(如果已存档)

谢谢你。

4

1 回答 1

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
于 2014-09-16T00:17:23.963 回答