AWS S3 .NET SDK:DeleteObjectsRequest返回OK,但未删除对象

时间:2017-09-14 04:25:46

标签: .net amazon-web-services amazon-s3 sdk

我有以下代码来删除S3“文件夹”中的对象:

DeleteObjectsRequest req = new DeleteObjectsRequest();
req.BucketName = "mybucket/my foder 1/my folder 2";
req.AddKey("photo1.jpg", null);
req.AddKey("photo2.jpg", null);
DeleteObjectsResponse response = client.DeleteObjects(req);

response.HttpStatusCode是OK,而response.DeletedObjects.Count是2.但是,实际的对象仍然存在。为什么呢?

在创建要删除的文件夹之前,此存储桶的版本控制已打开然后暂停。

1 个答案:

答案 0 :(得分:0)

我找到了。它应该是这样的:

DeleteObjectsRequest req = new DeleteObjectsRequest();
req.BucketName = "mybucket";
req.AddKey("my foder 1/my folder 2/photo1.jpg", null);
req.AddKey("my foder 1/my folder 2/photo2.jpg", null);
req.AddKey("my foder 1/my folder 2/", null);
DeleteObjectsResponse response = client.DeleteObjects(req);