Lua
Lua
S3 Upload a File with Public Read Permissions
See more Amazon S3 Examples
Demonstrates how to upload a file to the Amazon S3 service with the x-amz-acl request header set to "public-read" to allow the file to be publicly downloadable.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 AWS keys here:
http.aws_access_key = "AWS_ACCESS_KEY"
http.aws_secret_key = "AWS_SECRET_KEY"
local bucketName = "chilkat.ocean"
local objectName = "seahorse.jpg"
local localFilePath = "qa_data/jpg/seahorse.jpg"
local contentType = "image/jpg"
-- Add the x-amz-acl request header to make the file publicly readable.
http:set_request_header("x-amz-acl", "public-read")
local success = http:s3_upload_file(localFilePath, contentType, bucketName, objectName)
if not success then
print(http.last_error_text)
return
end
if http.last_status == 200 then
print("File uploaded.")
else
print("Response status code: " .. http.last_status)
print(http.last_response_body)
end