如何检查的子文件夹的大小为亚马逊S3存储中的文件夹 [英] How to check the size of the sub-folder for a folder inside a Amazon S3 bucket
问题描述
我想要做的是,我要检查的大小的子文件夹的特定文件夹中使用VB在亚马逊S3斗一斗。
What i want to do is, i want to check the Size for a sub-folder inside a specific folder for a bucket in Amazon S3 bucket using vb.
这是可能的事情,如果这样任何一个环节,并帮助将appriciated。
Is that possible to do, if so any link and help will be appriciated.
推荐答案
这篇文章的开始使用Amazon S3 是一个很好的起点为您服务。在code位引用的ListObject方法是做99%你想要什么(获得与特定的preFIX所有文件)。你只需要添加位询问每个文件的大小,并把它们加起来。
The article Beginning with Amazon S3 is a good starting point for you. The code bits referencing the listObject method are doing 99% of what you want (getting all files with a particular prefix). You just need to add the bits to interrogate the file size of each and add them up.
如果你能得到桶,那么你已经拥有你所需要的这个片段的工作线了:
If you're able to get the bucket, then you already have all the wire up you need for this snippet to work:
using (s3Client)
{
long totalFileSize = 0;
try
{
ListObjectsRequest Lor = new ListObjectsRequest()
{
BucketName = "<Your Bucket Name>",
Prefix = "<Your Folder Path>",
///assuming your delimiter is a /
Delimiter = "/"
};
ListObjectsResponse response1 = s3Client.ListObjects(Lor);
foreach (S3Object s3Object in response1.S3Objects)
{
totalFileSize += s3Object.Size();
}
}
catch (AmazonS3Exception ex)
{
///do some error handling....
}
}
这篇关于如何检查的子文件夹的大小为亚马逊S3存储中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!