Skip to content

Simple S3 utilities built with Bun, leveraging its native performance and APIs

Notifications You must be signed in to change notification settings

AltairInglorious/s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@amadeustech/s3

Simple S3 utilities built with Bun, leveraging its native performance and APIs.

Overview

This package provides a lightweight CLI tool, s3cp, for uploading files to any S3-compatible storage (AWS S3, Cloudflare R2, MinIO, etc.).


Environment Variables

All credentials and configuration are provided via environment variables:

Variable Description
S3_ACCESS_KEY_ID Access key for your S3 account
S3_SECRET_ACCESS_KEY Secret key for your S3 account
S3_ENDPOINT S3 endpoint URL (e.g., https://example.r2.cloudflarestorage.com)
S3_BUCKET Default bucket name
S3_REGION (Optional) Region name (e.g., us-east-1)
S3_SESSION_TOKEN (Optional) Temporary session token if using STS credentials

Installation

Install globally with Bun:

bun add -g @amadeustech/s3

This installs the s3cp binary, which you can use to copy files to S3-compatible storage.

Usage Example

Here’s how to upload database backups to Cloudflare R2:

#!/usr/bin/env bash

# Set S3 credentials (Cloudflare R2 example)
export S3_ACCESS_KEY_ID=foo
export S3_SECRET_ACCESS_KEY=bar
export S3_ENDPOINT=https://example.r2.cloudflarestorage.com
export S3_BUCKET=backups

# Path to the backup file
BACKUP_FILE=/var/backups/myapp/backup-2025-10-20.db.gz.gpg

# (Mock example) Create a database backup
make_db_backup -o "$BACKUP_FILE"

# Upload to /myapp/backup-2025-10-20.db.gz.gpg in the bucket
s3cp --to myapp "$BACKUP_FILE"

# Upload to /myorg/myapp/backup-2025-10-20.db.gz.gpg
s3cp --to myorg/myapp "$BACKUP_FILE"

# Upload directly to the bucket root: /backup-2025-10-20.db.gz.gpg
s3cp "$BACKUP_FILE"

Notes

The --to flag specifies an object path prefix inside your bucket.

Compatible with any S3-like service (AWS, R2, MinIO, DigitalOcean Spaces, etc.).

Designed for scripts and automation (ideal for backup pipelines).

Contributing

Contributions are welcome! 🎉 If you’d like to add new features, improve existing ones, or fix bugs — please open an issue or a pull request.

Getting Started

  1. Fork this repository and clone your fork locally.
  2. Install dependencies:
bun install
  1. Create a new branch for your feature or fix:
git checkout -b feature/your-feature-name
  1. Make your changes and ensure the code runs properly with Bun.
  2. Commit your changes with a clear message:
git commit -m "feat: add new cool stuff"
  1. Push your branch and open a Pull Request on GitHub.

About

Simple S3 utilities built with Bun, leveraging its native performance and APIs

Topics

Resources

Stars

Watchers

Forks