AWS S3 LS命令也返回文件夹名称以及其中的文件
这似乎是一个愚蠢的问题,但我找不到这样做的原因。当我在S3 URI上运行命令AWS S3 LS时,它给出了某些存储桶中输出中的父文件夹的名称,而对于某些存储库来说,它将仅列出文件夹中的文件。
示例:
aws s3 ls s3://test-bucket/test_folder/ --recursive --human-readable --summarize
2022-06-28 20:04:36 0 Bytes test_folder/
2022-06-28 20:05:58 3.0 KiB test_folder/file.txt
内容
aws s3 ls s3://sample_/sample_test/ --recursive --human-readable --summarize
2021-06-29 03:24:08 5.2 sample_test/file1.txt
2021-06-29 03:24:07 7.0 sample_test/file2.txt
2021-06-29 03:24:08 5.1 sample_test/file3.txt
对于另一个S3 URI,它将仅列出我不确定是什么原因导致这种行为的
,我在这里是否缺少任何文档,谢谢
This might seem like a stupid question but I am not able to find a reason for this. When I am running command aws s3 ls on S3 URI, it gives the name of parent folder in output for some of the buckets and for some it will just list the files in the folder.
Example:
aws s3 ls s3://test-bucket/test_folder/ --recursive --human-readable --summarize
2022-06-28 20:04:36 0 Bytes test_folder/
2022-06-28 20:05:58 3.0 KiB test_folder/file.txt
and for another s3 URI it will just list the contents
aws s3 ls s3://sample_/sample_test/ --recursive --human-readable --summarize
2021-06-29 03:24:08 5.2 sample_test/file1.txt
2021-06-29 03:24:07 7.0 sample_test/file2.txt
2021-06-29 03:24:08 5.1 sample_test/file3.txt
I am not sure what is causing this behavior, is there any documentation which I am missing here
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是因为有人使用S3控制台明确创建一个名为
test_folder
的“文件夹”,但他们没有为sample_test
而这样做。他们只是将3个文件上传到sample_test
。您认为的文件夹
test_folder/
只是一个S3对象,其键是test_folder/
,其大小为零。您不需要能够将文件上传到test_folder/
。这只是S3控制台中的视觉便利。S3中通常没有真正的文件夹。它们是虚拟的,并且是从有多个对象的存在中推断出的,其前缀为前斜线,例如
dogs/bingo.png
和dogs/elvis.jpg
意味着存在一个名为狗/
的虚拟文件夹,但实际上并不存在(通常)。This is likely because someone used the S3 console to explicitly create a 'folder' named
test_folder
but they didn't do that forsample_test
. They simply uploaded 3 files tosample_test
.What you see as the folder
test_folder/
is simply an S3 object whose key istest_folder/
and whose size is zero. It doesn't need to exist for you to be able to upload files totest_folder/
. It's just a visual convenience in the S3 console.There are typically no real folders in S3. They're virtual, and inferred from the presence of multiple objects with a common prefix ending in forward slash e.g.
dogs/bingo.png
anddogs/elvis.jpg
implies the presence of a virtual folder nameddogs/
, but it doesn't really exist (typically).