Reputation: 5792
I am using .net, and I am trying to delete an object from my S3 bucket. I tried the following:
Amazon.S3.AmazonS3Client client = new Amazon.S3.AmazonS3Client(Properties.Settings.Default.AmazonS3VideoSrcKey, Properties.Settings.Default.AmazonS3VideoSrcSecret);
client.DeleteObject(new Amazon.S3.Model.DeleteObjectRequest() { BucketName = "xxxx", Key = "http://....../filename"});
I dont get IsDeleteMarker true.
What can be wrong?
thanks
Upvotes: 9
Views: 19164
Reputation: 1
ListVersionsResponse listResponse = client.ListVersions(new ListVersionsRequest {
BucketName = bucketName,
Prefix = keyName }
);
List<S3ObjectVersion> listversion = listResponse.Versions;
foreach (S3ObjectVersion VersionIDs in listResponse.Versions)
{
if(VersionIDs.IsDeleteMarker)
{
DeleteObjectRequest request = new DeleteObjectRequest
{
BucketName = bucketName,
Key = keyName,
VersionId = VersionIDs.VersionId
};
client.DeleteObjectAsync(request);
}
}
Upvotes: -2
Reputation: 10052
Does your keys have an http://... prefix?
My guess is that you are mistakenly passing a URL instead of a key. Your request should probably look more like this:
client.DeleteObject(new Amazon.S3.Model.DeleteObjectRequest() { BucketName = "xxxx", Key = "filename"});
Upvotes: 22