如何解决如何从digitalocean空间对象存储中删除多个密钥?
我试图通过使用delete_objects删除多个对象。但是我遇到一个错误。我没有找到有关此问题的任何解决方案。
client = boto3.client("s3",**config)
response = client.delete_objects(
Bucket=BUCKET,Delete={
'Objects': [
{
'Key': 'asdasd1.png',},{
'Key': 'asdasd1.png',}
]
},RequestPayer='requester'
)
我收到这样的错误:
An error occurred (NotImplemented) when calling the DeleteObjects operation: Unknown
INFO: 127.0.0.1:46958 - "DELETE /image/ HTTP/1.1" 500 Internal Server Error
解决方法
也许这可以为您提供帮助,这是另一种方式
def cleanup_from_s3(bucket,remote_path):
s3_contents = list_s3(bucket,remote_path)
if s3_contents == []:
return
for s3_content in s3_contents:
filename = s3_content["Key"]
s3_client.delete_object(Bucket=bucket,Key="{0}/{1}".format(remote_path,filename))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。