Skip to content
/ s3 Public

Dependency-free S3 client when full SDK is not needed

Notifications You must be signed in to change notification settings

litejs/s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LiteJS S3 – Coverage Size Buy Me A Tea

Dependency-free S3 client when full SDK is not needed.

Usage

var S3 = require("@litejs/s3")
, s3client = new S3({ accessId: ID, secret: SECRET, region: "us-east-2", endpoint: "BUCKET.s3.us-east-2.amazonaws.com" })

// More client initialization examples
, awsDeprecatedPathStyle = new S3({ region: AWS_REGION, accessId: ID, secret: SECRET, bucket: AWS_BUCKET })
, googleCloudStorage = new S3({ accessId: ID, secret: SECRET, region: "auto", endpoint: "storage.googleapis.com" })
, cloudflareR2 = new S3({ accessId: ID, secret: SECRET, region: "auto", endpoint: "MY-ID.r2.cloudflarestorage.com" })


// Use with await (throws without catch)
var data = await s3client.get("test/hello.txt")

// .. or with callback
s3client.get("test/hello.txt", function(err, data) {
	console.log("Got file", data)
})

// .. or stream to client
require("http").createServer(function(req, res) {
	s3client.get("server-test.txt", res).catch(function(err) {
		res.end(err.message)
	})
})

// bucket exists
s3client.stat("test/")
s3client.list("test/", { maxKeys: 20 })
s3client.stat("test/hello.txt")
s3client.put("test/hello.txt", "Hello world!", {
	meta: { key: "User custom metadata" },
}, function(err) {})
s3client.del("test/hello.txt")

Copyright (c) 2022-2024 Lauri Rooden <[email protected]>
MIT License | GitHub repo | npm package | Buy Me A Tea