Reputation: 124
When attempting to delete an object via the S3 API (AWSSDK.S3 v3.1.0.0) I receive the following error messaging
[WebException: The remote server returned an error: (409) Conflict.]
[AmazonS3Exception: The bucket you tried to delete is not empty]
I am NOT attempting to delete a bucket, nor do I wish to delete a bucket.
This is the code in my class:
public static void Delete(string filename)
{
using (AmazonS3Client client = new AmazonS3Client(ACCESS_KEY_ID, SECRET_ACCESS_KEY, RegionEndpoint.USEast1))
{
var deleteRequest = new DeleteObjectRequest();
deleteRequest.BucketName = BUCKET;
deleteRequest.Key = Path.GetFileName(filename); //ensure only the filename is sent as key, not the path
client.DeleteObject(deleteRequest);
}
}
The API is pretty simple, the calling conventions are straight forward, any ideas why I would be getting a failure to delete a bucket while calling DeleteObject?
Upvotes: 2
Views: 2099
Reputation: 124
/facepalm
Stupid mistake, the calling code is passing NULL for the filename. Simply passing the correct filename solved the problem.
Upvotes: 1