Lua
Lua
S3 Upload File
See more Amazon S3 Examples
Demonstrates how to upload a file to the Amazon S3 service.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 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"
-- The Content-Type has the form type/subtype, such as application/pdf, application/json, image/jpeg, etc.
-- See Explaining Content-Types
local contentType = "image/jpeg"
local success = http:s3_upload_file(localFilePath, contentType, bucketName, objectName)
if not success then
print(http.last_error_text)
else
print("File uploaded.")
end