在列出同一存储桶中文件夹的内容时,我注意到不同的结果,具体来说,有时主文件夹将列在“内容”部分(在关键元素内)下,但有时不会。请参阅以下两个输出:
此输出不包括前缀目录
<?xml version='1.0' encoding='UTF-8'?>
<ListBucketResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'>
<Name>
test22</Name> <=== Bucket
<Prefix>
16-Jul-2013</Prefix> <=== Prefixed folder
<Marker>
</Marker>
<IsTruncated>
false</IsTruncated>
<Contents>
<Key>
16-Jul-2013/0371.txt</Key> <=== ONLY OBJECTS LISTED
<Generation>
1374016944689000</Generation>
<MetaGeneration>
1</MetaGeneration>
<LastModified>
2013-07-16T23:22:24.664Z</LastModified>
<ETag>
"5d858b3ddbf51fb5ec4501799e637b47"</ETag>
<Size>
96712</Size>
<Owner>
<ID>
00b4903a97d860d9d5a7d98a1c6385dc6146049499b88ceae217eaee7a0b2ff4</ID>
</Owner>
</Contents>
但是这个输出确实
<?xml version='1.0' encoding='UTF-8'?>
<ListBucketResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'>
<Name>
test22</Name> <=== Bucket
<Prefix>
22-Aug-2013</Prefix> <=== Prefixed folder
<Marker>
</Marker>
<IsTruncated>
false</IsTruncated>
<Contents>
<Key>
22-Aug-2013/</Key> <=== FOLDER INCLUDED IN LIST
<Generation>
1377178774399000</Generation>
<MetaGeneration>
1</MetaGeneration>
<LastModified>
2013-08-22T13:39:34.337Z</LastModified>
<ETag>
"d41d8cd98f00b204e9800998ecf8427e"</ETag>
<Size>
0</Size>
<Owner>
<ID>
00b4903a97d0b7e1f638009476bba4c5d964f744e50c23c3681357a290cb7b16</ID>
</Owner>
</Contents>
这两个请求都是使用以下代码发出的(注意我没有使用经过身份验证的会话,这些项目是公开可读的):
uri = URI('https://storage.googleapis.com/test22?prefix=16-Jul-2013') <=== prefix changed for each case
req3 = Net::HTTP::Get.new(uri.request_uri)
#req3['Authorization'] = "#{token['token_type']} #{token['access_token']}"
req3['Content-Length'] = 0
req3['content-Type'] = 'text/plain - GB'
req3['Date'] = Time.now.strftime("%a, %d %b %Y %H:%M:%S %Z")
req3['Host'] = 'storage.googleapis.com'
req3['x-goog-api-version'] = 2
req3['x-goog-project-id'] = ###############
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') { |http|
resp3 = http.request(req3)
puts resp3.body.gsub(/>/, ">\n")
}
为什么有区别?我缺少一些基本的东西吗?提前致谢...
-李