Im trying to delete an object on S3 using the ruby aws-sdk (version 2). It works fine, but it returns this
<struct Aws::S3::Types::DeleteObjectOutput delete_marker=nil,version_id=nil, request_charged=nil>
Which doesnt make sense because in the documentation it says the response should be of the type:
resp.delete_marker #=> true/false
resp.version_id #=> String
resp.request_charged #=> String, one of "requester"
Why am I becoming nil? I want to know if the object was deleted or not. I am getting that response both when i succeed in deleting the object and when I dont.
This is the code Im using to delete the object:
creds = Aws::Credentials.new(user_access_key,
user_secret_key,
session_token)
s3 = Aws::S3::Client.new( region: 'eu-west-1',
credentials: creds)
key = "myKey.csv"
r = s3.delete_object(bucket: "myBucket",
key: key)
Your delete object was successful. The Amazon S3 API only returns those values under certain circumstances. In this case, your object was not in a versioned bucket (no version id or delete marker boolean), and is not configured for request-payer.
As a general rule, if the SDK does not raise an error from the response, it is successful. In this case, the API reference documentation may be confusing as it does not clearly indicate that these values may be
nil
.aws-sdk-ruby Aws::CloudFormation::Client#delete_stack Documentation