s3utils

package module
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0

README

S3 Utils

Go library and CLI tools for interacting with S3-compatible object storage (MinIO, AWS S3, etc.).

Installation

go get github.com/bborbe/s3-utils

Library Usage

import s3utils "github.com/bborbe/s3-utils"

client := s3utils.CreateS3Client(
    s3utils.URL("http://localhost:9000"),
    s3utils.AccessKey("myaccesskey"),
    s3utils.SecretKey("mysecretkey"),
)

CLI Commands

All commands share these common environment variables / flags:

Flag Env Description
--s3-url S3_URL URL of the S3 server
--s3-access-key S3_ACCESS_KEY Access key
--s3-secret-key S3_SECRET_KEY Secret key
download

Downloads an object from S3 to stdout.

S3_URL=http://localhost:9000 \
S3_ACCESS_KEY=access \
S3_SECRET_KEY=secret \
BUCKET=mybucket \
KEY=myfile.txt \
./download > myfile.txt
upload

Uploads stdin to an S3 object.

cat myfile.txt | \
S3_URL=http://localhost:9000 \
S3_ACCESS_KEY=access \
S3_SECRET_KEY=secret \
BUCKET=mybucket \
KEY=myfile.txt \
./upload
list-buckets

Lists all buckets.

S3_URL=http://localhost:9000 \
S3_ACCESS_KEY=access \
S3_SECRET_KEY=secret \
./list-buckets
list-objects

Lists all objects in a bucket.

S3_URL=http://localhost:9000 \
S3_ACCESS_KEY=access \
S3_SECRET_KEY=secret \
BUCKET=mybucket \
./list-objects

Development

make test        # run tests
make precommit   # format, vet, lint, test

License

BSD-2-Clause — see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateS3Client

func CreateS3Client(
	s3Url URL,
	s3AccessKey AccessKey,
	s3SecretKey SecretKey,
) *s3.Client

Types

type AccessKey added in v0.0.2

type AccessKey string

func (AccessKey) String added in v0.0.2

func (a AccessKey) String() string

type SecretKey added in v0.0.2

type SecretKey string

func (SecretKey) String added in v0.0.2

func (s SecretKey) String() string

type URL added in v0.0.2

type URL string

func (URL) String added in v0.0.2

func (u URL) String() string

Directories

Path Synopsis
cmd
download command
list-buckets command
list-objects command
upload command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL