Lua
Lua
S3 Delete Bucket Object
See more Amazon S3 (new) Examples
Deletes an object in a bucket.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local rest = chilkat.Rest.new()
-- Connect to the Amazon AWS REST server.
local bTls = true
local port = 443
local bAutoReconnect = true
local success = rest:connect("s3.amazonaws.com", port, bTls, bAutoReconnect)
-- ----------------------------------------------------------------------------
-- Important: For buckets created in regions outside us-east-1,
-- there are three important changes that need to be made.
-- See Working with S3 Buckets in Non-us-east-1 Regions for the details.
-- ----------------------------------------------------------------------------
-- Provide AWS credentials for the REST call.
local authAws = chilkat.AuthAws.new()
authAws.access_key = "AWS_ACCESS_KEY"
authAws.secret_key = "AWS_SECRET_KEY"
authAws.service_name = "s3"
success = rest:set_auth_aws(authAws)
-- Set the bucket name via the HOST header.
-- In this case, the bucket name is "chilkat100".
rest.host = "chilkat100.s3.amazonaws.com"
-- This example deletes the object named "Abc.ics"
local sbResponse = chilkat.StringBuilder.new()
success = rest:full_request_no_body_sb("DELETE", "/Abc.ics", sbResponse)
if not success then
print(rest.last_error_text)
return
end
-- If successfully deleted, the response status code is 204 and the response body text will be empty.
local statusCode = rest.response_status_code
print("Response status code = " .. statusCode)
print("Response text = ")
print(sbResponse:get_as_string())