使用AWS-SDK删除整个对象目录树 [英] Remove entire object directory tree using AWS-SDK

查看:110
本文介绍了使用AWS-SDK删除整个对象目录树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用aws-sdk,并且尝试使用#delete_object方法删除对象,例如:

I'm using the aws-sdk, and I'm trying to delete an object with the #delete_object method, for example:

s3.delete_object(bucket: ENV["AWS_BUCKET"]), key: "images/123/myimage.png"))

如何删除路由(即"images/123")而不是仅删除.png文件?我不要空的文件夹".我已经测试过仅在key参数中添加路由的第一部分(s3.delete_object(bucket: ENV["AWS_BUCKET"]), key: "images/")),但是不起作用.谢谢!

How can I delete the route (that's "images/123") instead of only the .png file? I don't want empty "folders". I've tested adding only the first part of the route (s3.delete_object(bucket: ENV["AWS_BUCKET"]), key: "images/")) in the key parameter but doesn't work. Thanks!

推荐答案

文件夹为空时将自动删除.

The folder will auto delete when it's empty.

因此,如果您删除文件并刷新根文件夹,您会发现它已经消失了! Aws-Magic =)

So if you delete your file and refresh the root folder, you will see that it's gone ! Aws-Magic =)

这篇关于使用AWS-SDK删除整个对象目录树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆