У меня есть функция для извлечения метаданных из моего сегмента S3, но у меня проблема с получением значения моих метаданных определения.
[HttpGet]
public async Task<IActionResult> GetUnpublishedVideos()
{
using (var client = new AmazonS3Client(_config.GetValue<string>("AWS:accessKey"),
_config.GetValue<string>("AWS:secretKey"), RegionEndpoint.APSoutheast2))
{
try
{
ListObjectsV2Request request = new ListObjectsV2Request
{
BucketName = _config.GetValue<string>("AWS:bucket"),
MaxKeys = 10
};
ListObjectsV2Response response;
do
{
response = await client.ListObjectsV2Async(request);
List<GetObjectMetadataResponse> metaList = new List<GetObjectMetadataResponse>();
// Process the response.
foreach (S3Object entry in response.S3Objects)
{
var meta = await client.GetObjectMetadataAsync(_config.GetValue<string>("AWS:bucket"), entry.Key);
request.ContinuationToken = response.NextContinuationToken;
if (meta.Metadata == null || meta.Metadata.Count == 0)
{
break;
}
//This is the problem, I can only find the meta.metadata.Keys, but I cannot
have the value.
metaList.Add(meta);
}
return Ok(metaList);
} while (response.IsTruncated);
}
catch (AmazonS3Exception amazonS3Exception)
{
//Console.WriteLine("S3 error occurred. Exception: " + amazonS3Exception.ToString());
return BadRequest("S3 error occurred. Exception: " + amazonS3Exception.ToString());
}
catch (Exception e)
{
//Console.WriteLine("Exception: " + e.ToString());
return BadRequest("Exception: " + e.ToString());
}
}
}
Это объект, который я загружаю в S3, есть два пользовательских метаданные, как показано на рисунке ниже. Как я могу получить значение ???
![enter image description here](https://i.stack.imgur.com/n0cqc.png)