Skip to content

PlutoLang/pluto-s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pluto-s3

S3 client library written in Pluto, including AWS4 and HMAC algorithms.

Exports

function aws4_date()
function aws4_sign(user, pass, method, encoded_path, signed_headers, region = "us-east-1", service = "s3")
function aws4_auth(user, pass, method, encoded_path, signed_headers, region = "us-east-1", service = "s3")

class S3
    function __construct(url, region = "es-east-1")
    function request(method, path, content, headers = {})
    function ListBuckets()

class S3Bucket extends S3
    function ListObjects()
    function PutObject(name, mime_type, content)
    function GetObject(name)
    function DeleteObject(name)

Examples

These examples assume a local minio setup with default credentials. Note that minio buckets don't have their own hostname so are accessed by adding a base path.

List buckets

local { S3 } = require "s3"
local s3 = new S3("http://minioadmin:minioadmin@localhost:9000")
print(dumpvar(s3:ListBuckets()))

List objects in bucket

local { S3Bucket } = require "s3"
local mybucket = new S3Bucket("http://minioadmin:minioadmin@localhost:9000/mybucket")
print(dumpvar(mybucket:ListObjects()))

Put object

local { S3Bucket } = require "s3"
local mybucket = new S3Bucket("http://minioadmin:minioadmin@localhost:9000/mybucket")
mybucket:PutObject("pluto-hello.txt", "text/plain", "Hello from Pluto!")

Get object

local { S3Bucket } = require "s3"
local mybucket = new S3Bucket("http://minioadmin:minioadmin@localhost:9000/mybucket")
print(mybucket:GetObject("pluto-hello.txt")) --> Hello from Pluto!

Delete object

local { S3Bucket } = require "s3"
local mybucket = new S3Bucket("http://minioadmin:minioadmin@localhost:9000/mybucket")
mybucket:DeleteObject("pluto-hello.txt")

About

S3 client library written in Pluto, including AWS4 and HMAC algorithms.

Topics

Resources

License

Stars

Watchers

Forks

Languages