我在Amazon s3 Bucket中有多个对象,每个对象都有一个自定义元数据(" x-amz-meta-cod")。我按以下方式放置元数据:
putRequest2.Metadata.Add("x-amz-meta-cod", "53");
因此,为了查询我的所有对象,我按以下方式进行:
static void ListObjects()
{
try
{
ListObjectsV2Request request = new ListObjectsV2Request
{
BucketName = "test",
};
ListObjectsV2Response response;
do
{
response = client.ListObjectsV2(request);
// Process response.
foreach (S3Object entry in response.S3Objects)
{
Console.WriteLine("key = {0} Size = {1}",
entry.Key, entry.Size);
}
Console.WriteLine("Next Continuation Token: {0}", response.NextContinuationToken);
request.ContinuationToken = response.NextContinuationToken;
} while (response.IsTruncated == true);
}
catch (AmazonS3Exception amazonS3Exception)
{
if (amazonS3Exception.ErrorCode != null &&
(amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId")
||
amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
{
Console.WriteLine("Check the provided AWS Credentials.");
Console.WriteLine(
"To sign up for service, go to http://aws.amazon.com/s3");
}
else
{
Console.WriteLine(
"Error:'{0}'",
amazonS3Exception.Message);
}
}
}
我的问题是,如何只使用" x-amz-meta-cod" =" 50" ? 我需要帮助!感谢。