简体   繁体   English

如何使用 S3API 或任何其他实用程序在 S3 Bucket 中查找“仅文件夹”?

[英]How to find "folder only" in S3 Bucket using S3API or any other utils?

How to get list of "only" Folders (List unknown at this time) in a S3 bucket that has over 80 million objects/keys?如何在具有超过 8000 万个对象/键的 S3 存储桶中获取“唯一”文件夹列表(此时列表未知)?

Vendor initially uploaded several millions gz files directly on the root of the bucket (Bucket-Vend) instead of creating folders.供应商最初将数百万个 gz 文件直接上传到存储桶的根目录 (Bucket-Vend),而不是创建文件夹。 When they realized, they then created folder under Bucket-Vend;当他们意识到时,他们在 Bucket-Vend 下创建了文件夹; however did not remove the millions of individual files.但是并没有删除数百万个单独的文件。 To cleanup the mess, we are looking to see if we can get "just" the folder names directly under this bucket (Bucket-Vend).为了清理混乱,我们正在寻找是否可以直接在此存储桶(Bucket-Vend)下“仅”获取文件夹名称。 We have tried using Cloudwatch and S3api but unfortunately we are not able to get a list of just Folders at this bucket level.我们已尝试使用 Cloudwatch 和 S3api,但不幸的是,我们无法获得此存储桶级别的文件夹列表。 The idea is once we know the folders, we could then move the folders to another bucket and then delete all the individual files and finally the bucket (Bucket-Vend).这个想法是一旦我们知道文件夹,我们就可以将文件夹移动到另一个存储桶,然后删除所有单个文件,最后删除存储桶(Bucket-Vend)。 Any help is appreciated please!任何帮助表示赞赏!

Given the number of objects in your bucket, I would recommend using Amazon S3 Inventory , to obtain a daily CSV listing all objects in the bucket.鉴于您的存储桶中的对象数量,我建议使用Amazon S3 Inventory来获取列出存储桶中所有对象的每日 CSV 文件。

The folders might appear as zero-length objects, or you could just extract the folder names from the object names (eg folder1/foo.txt is in folder1 ).文件夹可能显示为零长度对象,或者您可以只从对象名称中提取文件夹名称(例如folder1/foo.txtfolder1 )。

Given the list, you could then write a program to copy the objects to their desired location, or use the AWS Command-Line Interface (CLI) aws s3 mv command that will both "move" the objects (by doing a copy and delete).给定列表,然后您可以编写程序将对象复制到所需位置,或使用AWS 命令​​行界面 (CLI) aws s3 mv命令来“移动”对象(通过执行复制和删除) . It can also "move" a folder between buckets.它还可以在存储桶之间“移动”文件夹。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM