Lua
Lua
S3 Delete File
See more Amazon S3 Examples
Demonstrates how to delete a remote file (object) on the Amazon S3 service.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat HTTP API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- Insert your access key here:
http.aws_access_key = "AWS_ACCESS_KEY"
-- Insert your secret key here:
http.aws_secret_key = "AWS_SECRET_KEY"
local bucketName = "chilkattest"
local objectName = "starfish.jpg"
http.keep_response_body = true
local success = http:s3_delete_object(bucketName, objectName)
if not success then
print(http.last_error_text)
return
end
if http.last_status ~= 204 then
print("Status code = " .. http.last_status)
print(http.last_response_body)
print("Failed.")
return
end
-- 204 is the success response status.
-- When successful, the response body will be empty.
print("Status code = " .. http.last_status)
print("Success. Object deleted.")