Lua
Lua
S3 Download String Object
See more Amazon S3 Examples
Demonstrates how to download a text file (i.e. object) from the Amazon S3 service directly into an in-memory string variable.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat 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"
-- This bucket is in the us-east-1 region.
http.aws_region = "us-east-1"
local bucketName = "chilkat-test-bucket"
local objectName = "fruit.xml"
local charset = "utf-8"
local fileContents = http:s3_download_string(bucketName, objectName, charset)
if not http.last_method_success then
-- Failed
print(http.last_error_text)
else
-- Success
print(fileContents)
end