简体   繁体   English

如何编写 S3 存储桶策略以在 s3 存储桶中的文件夹内立即禁用批量删除但允许用户单独下载?

[英]How to write S3 bucket policy to disable bulk delete at once inside a folder in s3 bucket but allow users to download it individually?

I have an S3 bucket with the following structures.我有一个具有以下结构的 S3 存储桶。

/
|-- folder1
|   |-- img1.jpg
|   |-- img2.jpg
|   |-- img3.jpg
|   `-- somedata
|       `-- file.mp3
`-- folder2
    |-- img1.jpg
    |-- img2.jpg
    |-- img3.jpg
    `-- somedata
        `-- file.mp3

Now, I don't want any user to delete the contents of any folders ie folder1 or folder2 at once, but if they want they can do it individually, one at a time.现在,我不希望任何用户一次删除任何文件夹(即folder1folder2 )的内容,但如果他们愿意,他们可以一次一个地单独删除。 Like delete folder1/img1.jpg , folder1/img2.jpg but should not be able to select img1.jpg , img2.jpg , img3.jpg , somedata/file.mp3 from the console and delete in one go.喜欢删除folder1/img1.jpgfolder1/img2.jpg但不应该能够从控制台删除 select img1.jpgimg2.jpgimg3.jpgsomedata/file.mp3并删除一个 go 。

There is no command in Amazon S3 to "delete folders". Amazon S3 中没有“删除文件夹”的命令。 Each object must be deleted individually.每个 object 必须单独删除。

Even if you use a utility such as the AWS Command-Line Interface (CLI) , it simply loops through the objects and deletes them one-at-a-time.即使您使用诸如AWS 命令行界面 (CLI)之类的实用程序,它也只是循环遍历对象并一次删除一个对象。

So, users cannot actually "delete folders".所以,用户实际上不能“删除文件夹”。 Thus, it is not possible to 'disable bulk delete' since there is no bulk delete capability.因此,不可能“禁用批量删除”,因为没有批量删除功能。 (Unless you use Amazon S3 Lifecycle.) (除非您使用 Amazon S3 生命周期。)

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

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