简体   繁体   English

读取公共AWS S3存储桶中的文件计数

[英]Read the file count in a public AWS S3 bucket

I am able to retrieve the XML which contains the info about the files using the below piece of code: 我可以使用下面的代码来检索包含有关文件信息的XML:

XElement responseXML = XElement.Load(AWS_S3_URL);        
ICollection<XElement> fileElements = responseXML.Elements("Contents") as ICollection<XElement>;
Debug.Log("responseXML.Elements() ===== " + fileElements.ToString());

The first line of code returns the following xml. 代码的第一行返回以下xml。 But I am not able to retrieve the count of element: 但是我无法检索元素的数量:

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Name>XXXXXXXXXXXX</Name>
    <Prefix />
    <Marker />
    <MaxKeys>1000</MaxKeys>
    <IsTruncated>false</IsTruncated>
    <Contents>
        <Key>AffectivaLogs/</Key>
        <LastModified>2018-04-16T00:20:06.000Z</LastModified>
        <ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag>
        <Size>0</Size>
        <Owner>
            <ID>65a011a29cdf8ec533ec3d1ccaae921c</ID>
        </Owner>
        <StorageClass>STANDARD</StorageClass>
    </Contents>
    <Contents>
        <Key>Bean Man with Affectiva.Editor.csproj</Key>
        <LastModified>2018-04-16T05:40:43.000Z</LastModified>
        <ETag>"7ea67a5fa37ceaeaa90ef3dbebddb201"</ETag>
        <Size>34349</Size>
        <StorageClass>STANDARD</StorageClass>
    </Contents>
</ListBucketResult>

Able to do it easily using XmlDocument instead of XElement . 可以使用XmlDocument而不是XElement轻松地做到这一点。

XmlDocument responseXML = new XmlDocument();
responseXML.Load(AWS_S3_URL);
XmlElement root = responseXML.DocumentElement;
XmlNodeList node = root.GetElementsByTagName("Contents");        
Debug.Log("responseXML.Elements() ===== " + node.Count);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS S3存储桶| 确定文件的日期计数和文件的年龄 - AWS S3 Bucket | Determine the count of file datewise and age of the file 从AWS S3存储桶读取Excel文件 - Read excel file from AWS S3 Bucket AWS S3存储桶临时证书下载文件.Net - AWS S3 bucket Temporary Credentials download file .Net 带有Amazon S3存储桶的AWS Sync文件 - AWS Sync files with amazon s3 bucket 需要使用c#实现AWS S3存储桶文件上传。 文件大小不受限制 - Need to implementation AWS S3 Bucket file upload using c#. Whereas file size is not limit 有没有办法使用适用于 .NET 的 AWS SDK 将对象从 S3 存储桶下载到文件目标? - Is there a way to download an object from S3 bucket to a file destination using AWS SDK for .NET? 使用AWS .NET SDK将文件上载到S3存储桶时,任务被取消了异常? - Task was cancelled exception when uploading file to S3 bucket using AWS .NET SDK? 如何将 AWS S3 存储桶 stream 响应转换为 .NET Core 中的文件 - How to Convert AWS S3 bucket stream response into a file in .NET Core -AWS C#.Net Core-如何将.jpg图像上传到S3存储桶而不将其另存为文件 - -AWS C# .Net Core- How to upload a .jpg image to S3 bucket without saving it as a file 将文件放入私有子网的 S3 存储桶中 - putting a file in S3 bucket in private subnet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM