![](/img/trans.png)
[英]AWS S3 Bucket | Determine the count of file datewise and age of the file
[英]Read the file count in a public AWS S3 bucket
我可以使用下面的代碼來檢索包含有關文件信息的XML:
XElement responseXML = XElement.Load(AWS_S3_URL);
ICollection<XElement> fileElements = responseXML.Elements("Contents") as ICollection<XElement>;
Debug.Log("responseXML.Elements() ===== " + fileElements.ToString());
代碼的第一行返回以下xml。 但是我無法檢索元素的數量:
<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>
可以使用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.