本文介绍了检索S3对象用户元 - AWS SDK V3 PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在找检索对象的用户定义的元数据在我的S3存储桶,从PHP SDK。
根据编辑对象元数据,用户元数据存储的对象,并使用它返回,并开始与X-AMZ-元 -
我已通过如x-AMZ-元测试控制台定义的用户的元数据上的目的,在两个载时间和上传之后加入它(通过web控制台,不上载的API)。
测试元数据再也没有回来。我总是得到相同的系统元数据。也就是说,我只得到了以下键@metadata:
文件夹
状态code
effectiveUri
头
的x AMZ-ID-2
的X AMZ-请求ID
日期
的X AMZ-桶区域
内容类型
传输编码
服务器
对象
键
上一次更改
日期
timezone_type
时区
ETag的
尺寸
StorageClass
然而,在其他语言中实现这一点,一个简单的方法调用参与。
获取Android SDK中用户元
获取的Java SDK 用户元
我如何去完成同样的任务在PHP SDK?
任何帮助将是很大的AP preciated:)
解决方案 。一些研究和测试后,我确定我可以使用
headObject
:
< PHP
$标题= $ S3-> headObject(阵列(
斗=> $桶,
键=> $关键
));
的print_r($包头中>的toArray());
?>
示例输出与系统定义的元数据并删除其他识别信息:
阵列
(
/ *删除* /
[元] =>排列
(
[订购日期] =>周一,2015年8月31日19时03分五十二秒+0000
[颜色] =>绿色
[水果] =>苹果
[参考价格] => 99.95
)
/ *删除* /
[@metadata] =>排列
(
[状态code] => 200
[effectiveUri] => https://s3.amazonaws.com/REMOVED/REMOVED
[标题] =>排列
(
[X-AMZ-ID-2] => REMOVED
[X-AMZ-请求ID] => REMOVED
[日期] =>星期三,2015年9月2日4点43分02秒格林尼治标准时间
[X-AMZ-元订购日期] =>周一,2015年8月31日19时03分五十二秒+0000
[X-AMZ-元彩] =>绿色
[X-AMZ-元水果] =>苹果
[X-AMZ-元价格] => 99.95
[上次修改] =>星期三,2015年9月2日4点11分13秒格林尼治标准时间
[ETAG] => 去掉
[X-AMZ-存储类] => REDUCED_REDUNDANCY
[接受-范围] =>字节
[内容类型] =>应用程序/八位字节流
[内容长度=> 80771
[服务器] => AmazonS3
)
)
)
I'm looking to retrieve user-defined meta-data from objects in my S3 bucket, from the php sdk.
As per Editing Object Meta Data, User metadata is stored with the object and returned with it, and begin with "x-amz-meta-"
I have defined user metadata on objects through the console like "x-amz-meta-test", at both upload time, and adding it after the upload (through web console, not the upload API).
The test metadata is never returned. I always get the same system metadata. That is, I get only the following keys in @metadata:
Folder
statuscode
effectiveUri
headers
x-amz-id-2
x-amz-request-id
date
x-amz-bucket-region
content-type
transfer-encoding
server
Objects
Key
LastModified
date
timezone_type
timezone
ETag
Size
StorageClass
However, to achieve this in other languages, a simple method call is involved.
Get User Metadata in Android SDK
Get User Metadata in Java SDK
How do I go about accomplishing the same task in the PHP SDK?
Any help would be greatly appreciated :)
解决方案
I had the same issue with v3 AWS SDK for PHP. After some research and testing, I determined I could use headObject
:
<?php
$headers = $s3->headObject(array(
"Bucket" => $bucket,
"Key" => $key
));
print_r($headers->toArray());
?>
Example output with System-Defined Metadata and other identifying information REMOVED:
Array
(
/* REMOVED */
[Metadata] => Array
(
[orderdate] => Mon, 31 Aug 2015 19:03:52 +0000
[color] => green
[fruit] => apple
[price] => 99.95
)
/* REMOVED */
[@metadata] => Array
(
[statusCode] => 200
[effectiveUri] => https://s3.amazonaws.com/REMOVED/REMOVED
[headers] => Array
(
[x-amz-id-2] => REMOVED
[x-amz-request-id] => REMOVED
[date] => Wed, 02 Sep 2015 04:43:02 GMT
[x-amz-meta-orderdate] => Mon, 31 Aug 2015 19:03:52 +0000
[x-amz-meta-color] => green
[x-amz-meta-fruit] => apple
[x-amz-meta-price] => 99.95
[last-modified] => Wed, 02 Sep 2015 04:11:13 GMT
[etag] => "REMOVED"
[x-amz-storage-class] => REDUCED_REDUNDANCY
[accept-ranges] => bytes
[content-type] => application/octet-stream
[content-length] => 80771
[server] => AmazonS3
)
)
)
这篇关于检索S3对象用户元 - AWS SDK V3 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!