Skip to main content

bucketbase

Project description

BucketBase

BucketBase offers a comprehensive suite of base classes tailored for abstracting object storage solutions. It's designed to facilitate seamless integration with different storage backends, including S3-compatible services (like Minio), in-memory storage for testing, and file-based storage for local development and caching purposes. This flexibility makes it an ideal choice for projects that require a unified API for object storage across various environments.

Features

  • S3 Compatible Storage Support: Use with any S3-compatible storage service like Minio, AWS S3, etc.
  • In-memory Storage: Perfect for testing purposes, avoiding the need for an actual object storage service.
  • File Storage: Ideal for local development and caching, simulating an object storage interface with local file system.
  • Extensible: Implement the IBucket interface to support additional storage backends.

Installation

Install BucketBase using pip:

pip install bucketbase

Quick Start To get started with BucketBase, first import the storage class you wish to use:

from bucketbase.memory_bucket import MemoryBucket
from bucketbase.minio_bucket import MinioBucket
from bucketbase.fs_bucket import FSBucket, AppendOnlyFSBucket

Using Memory Storage

Memory storage is useful for tests or development environments where no persistence is required.

bucket = MemoryBucket()
bucket.put_object("test.txt", "Hello, World!")
print(bucket.get_object("test.txt"))  # Outputs: b'Hello, World!'

Using File Storage

File storage is useful for local development and caching.

bucket = FSBucket("/path/to/storage")
bucket.put_object("hello.txt", "Hello, File Storage!")
print(bucket.get_object("hello.txt"))  # Outputs: b'Hello, File Storage!'

Using Minio (S3 Compatible Storage)

Ensure you have Minio server running and accessible.

from bucketbase.minio_bucket import MinioBucket

bucket = MinioBucket(endpoint="localhost:9000", access_key="minioadmin", secret_key="minioadmin", secure=False)
bucket.put_object("greet.txt", "Hello, Minio!")
print(bucket.get_object("greet.txt"))  # Outputs: b'Hello, Minio!'

Advanced Usage

For advanced usage, including error handling, listing objects, and more, refer to the IBucket interface and the specific implementation you are using. Each storage option may have additional methods and features tailored to its backend.

Contributing

Contributions are welcome! If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Licensing

The code in this project is licensed under MIT license.

Changelog

1.1.0 (breaking changes)
  • IBucket rename: get_object_content() -> get_object()
  • IBucket.fput_oject() rename arg: destination -> file_path
1.0.1
  • Added ShallowListing to init.py

This README.md provides a general overview of BucketBase, instructions for installation, a quick start guide for using its various storage options, and an invitation for contributions. It's structured to be informative and straightforward, allowing users to quickly get started with the project.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

bucketbase-1.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bucketbase-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for bucketbase-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc638286c461a44c270797f6f5433454ffba430d0f0bdbabc4c8e6140578174d
MD5 d62b347aa5bf5053cfc9c61794177118
BLAKE2b-256 538440573d3267844206921ae73ebe32f41b92836b826f6f9bd461dcfbed33ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page