AWS S3 LS命令也返回文件夹名称以及其中的文件

发布于 2025-02-11 18:38:06 字数 640 浏览 1 评论 0原文

这似乎是一个愚蠢的问题,但我找不到这样做的原因。当我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧话新听 2025-02-18 18:38:06

这可能是因为有人使用S3控制台明确创建一个名为test_folder的“文件夹”,但他们没有为sample_test而这样做。他们只是将3个文件上传到sample_test

您认为的文件夹test_folder/只是一个S3对象,其键是test_folder/,其大小为零。您不需要能够将文件上传到test_folder/。这只是S3控制台中的视觉便利。

S3中通常没有真正的文件夹。它们是虚拟的,并且是从有多个对象的存在中推断出的,其前缀为前斜线,例如dogs/bingo.pngdogs/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 for sample_test. They simply uploaded 3 files to sample_test.

What you see as the folder test_folder/ is simply an S3 object whose key is test_folder/ and whose size is zero. It doesn't need to exist for you to be able to upload files to test_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 and dogs/elvis.jpg implies the presence of a virtual folder named dogs/, but it doesn't really exist (typically).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文