delete S3 object
11,488
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"});
Author by
Himberjack
Updated on July 30, 2022Comments
-
Himberjack almost 2 years
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
-
Chen Harel over 12 yearsS3 supports folders by simply supporting "/" as part of the key. so for instance a key can be "folder/filename". Therefore when I wrote "filename" in my answer I meant the key to the object
-
Eugene Podskal almost 5 yearsWhile this code snippet may be the solution, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.