Skip to main content

Bucket Helper

🇫🇷 · 🇬🇧

CI License: BSD-3-Clause Python

Bucket Helper belongs to a collection of libraries called AI Helpers developed for building Artificial Intelligence.

Utility functions for AWS S3 and any S3-compatible object storage — MinIO, Backblaze B2 S3 API, DigitalOcean Spaces, Cloudflare R2, Wasabi, and friends. Built on boto3. Same shape as sftp-helper: a credentials() loader, the usual CRUD (upload / download / delete / exists / list_prefix), and a remote_tempfile context manager for stage-and-share flows.

🌍 AI Helpers

logo

Documentation

💻 Documentation

🗺️ Landscape

📋 Examples

🎯 Triggers

Installation

PrerequisitesPython 3.10–3.13 and git, cross-platform:

  • 🍎 macOS (Homebrew): brew install python git
  • 🐧 Ubuntu/Debian: sudo apt update && sudo apt install -y python3 python3-pip git
  • 🪟 Windows (PowerShell): winget install Python.Python.3.12 Git.Git

We recommend using Python environments. Check this link if you're unfamiliar with setting one up: 🥸 Tech tips.

From PyPI (recommended)

# Core library (credentials loader + CRUD + remote_tempfile)
pip install bucket-helper

# Optional surfaces
pip install "bucket-helper[cli]"       # click-based CLI twin
pip install "bucket-helper[api]"       # FastAPI HTTP surface

From source (no PyPI)

# Core library
pip install bucket-helper

# Optional surfaces
pip install "bucket-helper[cli]"
pip install "bucket-helper[api]"

The argparse CLI is always available. The [cli] extra adds the click twin.

Configuration

A ready-to-fill template is committed at s3_config.json.example. Copy it to s3_config.json and edit in place — real *config.json files are gitignored so you cannot accidentally commit secrets:

cp s3_config.json.example s3_config.json
# then edit s3_config.json with your AWS / MinIO / R2 / B2 credentials

You may also write a s3_config.yaml, use a .env, or set environment variables — bucket-helper falls back in that order via os_helper.get_config. Required keys:

{
  "s3_access_key": "AKIA...",
  "s3_secret_key": "...",
  "s3_bucket":     "my-bucket",
  "s3_https":      "https://my-bucket.s3.eu-west-3.amazonaws.com"
}

Optional keys:

Key Default Notes
s3_region "us-east-1" AWS region; mostly cosmetic for MinIO / R2
s3_endpoint_url empty (= AWS S3) Set this for S3-compatible backends — see table below
s3_prefix empty Default key prefix added by upload(...) when no destination is given
s3_use_path_style "false" Force path-style addressing (endpoint/bucket/key instead of bucket.endpoint/key). Typical for MinIO with custom domains.
s3_verify_ssl "true" Disable only for dev MinIO with self-signed certs

Endpoint URLs for common S3-compatible storage

Set s3_endpoint_url to:

Provider Endpoint
AWS S3 leave empty / unset
MinIO http://minio.example.com:9000 (or https://... with TLS)
DigitalOcean Spaces https://nyc3.digitaloceanspaces.com (region in subdomain)
Cloudflare R2 https://<account_id>.r2.cloudflarestorage.com
Backblaze B2 (S3 API) https://s3.<region>.backblazeb2.com
Wasabi https://s3.<region>.wasabisys.com

Usage

For the full catalog of recipes (uploads / downloads / listings, S3-compatible endpoints — MinIO / R2 / B2 / Spaces / Wasabi, temporary remote keys with auto-cleanup, mirroring with sftp-helper), see 📋 EXAMPLES.md.

import bucket_helper as bh

# Load creds — JSON / YAML / env / .env (auto-fallback in that order)
cred = bh.credentials("path/to/s3_config.json")

# Upload a local file
uri = bh.upload("local.txt", cred, "folder/uploaded.txt")
# uri == "s3://my-bucket/folder/uploaded.txt"

assert bh.exists(uri, cred)

# Download
bh.download(uri, "downloaded.txt", cred)

# List
for key in bh.list_prefix("folder/", cred):
    print(key)

# Delete
bh.delete(uri, cred)

MinIO example

cred = {
    "s3_access_key":      "minioadmin",
    "s3_secret_key":      "minioadmin",
    "s3_bucket":          "uploads",
    "s3_https":           "http://minio.example.com:9000/uploads",
    "s3_endpoint_url":    "http://minio.example.com:9000",
    "s3_use_path_style":  "true",
    "s3_region":          "us-east-1",  # MinIO accepts any region string
}

bh.make_bucket("uploads", cred)
bh.upload("file.bin", cred, "file.bin")

Stage-and-share with remote_tempfile

Drop a generated file at a unique random key, hand the public URL to a downstream worker / webhook, and the object is deleted on block exit (even if the body raises):

import bucket_helper as bh
import requests

cred = bh.credentials("path/to/s3_config.json")

with bh.remote_tempfile(cred, ext="json", prefix="runs") as (s3_addr, public_url):
    bh.upload("payload.json", cred, s3_addr, content_type="application/json")
    # Hand the URL to something that fetches it once.
    requests.post("https://hook.example.com/process", json={"input_url": public_url}).raise_for_status()
# Object is gone here, no manual cleanup.

Multi-surface exposure

Every public function in the library is also exposed as:

  • argparse CLIbucket-helper <subcommand> (installed by default).
  • click CLIbucket-helper-click <subcommand> (install [cli] extra).
  • FastAPI HTTPuvicorn bucket_helper.api:app --host 0.0.0.0 --port 8000 (install [api] extra).
  • MCPbucket-helper-mcp exposes the same HTTP surface as MCP tools for any MCP-aware agent host (install [mcp] extra).

Both CLIs share the same subcommand names and flags — pick your favourite.

The exhaustive catalogue of what triggers the toolkit — natural-language phrasings, commands, functions, address cues, and explicit SKIP rules — lives in TRIGGERS.md.

CLI examples

# argparse CLI (always available)
bucket-helper upload      --config s3_config.json --input local.txt --key folder/uploaded.txt
bucket-helper exists      --config s3_config.json --key folder/uploaded.txt
bucket-helper download    --config s3_config.json --key folder/uploaded.txt --output back.txt
bucket-helper list        --config s3_config.json --prefix folder/
bucket-helper delete      --config s3_config.json --key folder/uploaded.txt
bucket-helper make-bucket --config s3_config.json --bucket new-bucket
bucket-helper tempfile    --config s3_config.json --ext json --prefix runs
bucket-helper strip-path  --config s3_config.json --address s3://my-bucket/path/to/obj

# click CLI — same verbs, same flags
bucket-helper-click upload --config s3_config.json --input local.txt --key folder/uploaded.txt

HTTP server

# Serve HTTP (default credentials picked up from BUCKET_HELPER_CONFIG)
BUCKET_HELPER_CONFIG=$PWD/s3_config.json uvicorn bucket_helper.api:app --host 0.0.0.0 --port 8000
# → Swagger UI at http://localhost:8000/docs

Per-request credentials can also be sent as multipart form fields (s3_access_key / s3_secret_key / s3_bucket / s3_https / …).

Docker

docker build -t bucket-helper .
docker run --rm -p 8000:8000 \
  -e BUCKET_HELPER_CONFIG=/config/s3_config.json \
  -v $PWD/s3_config.json:/config/s3_config.json:ro \
  bucket-helper

See also: TRIGGERS.md (what invokes the toolkit) and GUI.md (visual product design plan — no GUI ships; bucket-helper is remote object-storage plumbing).

Author

Acknowledgements

Special thanks to Mohamed Chelali and Bachir Zerroug for fruitful discussions.

License

This project is licensed under the BSD-3-Clause License — see the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bucket_helper-1.1.0.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bucket_helper-1.1.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file bucket_helper-1.1.0.tar.gz.

File metadata

  • Download URL: bucket_helper-1.1.0.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for bucket_helper-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cf7514261eecdb8fcaaf13e715034b9ed81a3a94b79a6d912b5147e6f37f8cdb
MD5 f89e05c7d3d157ce5917f12e1d13103f
BLAKE2b-256 ae9606c9764709e61236b889be4d61c39f021595d3b3c4984eb73a93b10061c3

See more details on using hashes here.

File details

Details for the file bucket_helper-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: bucket_helper-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for bucket_helper-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 495063ebd5c4c9849fa82e96dd0f74248ff49503807eec5b0dd2f5a67e096654
MD5 f2decd64bad3d946717733bb3587f9cf
BLAKE2b-256 219c46f390361791ff2a15d2501a4b9136a53c5f8dc43e3a75fb359e8cc6ef54

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.2

2 files

1.1.1

2 files

This release

1.1.0 This release

2 files

1.0.0

2 files

0.4.1

2 files

0.3.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page