Skip to main content

A Python library designed to simplify interactions with Amazon S3 using the `aiobotocore` and `botocore` libraries. It provides asynchronous and synchronous classes for various S3 operations.

Project description

s3minimal - The Minimalist S3 Library

PyPI - Version

PyPI - Python Version

License: MIT

s3minimal is a Python library designed to simplify interactions with Amazon S3 using the aiobotocore and botocore libraries. It provides asynchronous and synchronous classes for various S3 operations.

Installation

pip install s3minimal

Usage

Initialization

Initialize the S3 class with your AWS credentials, endpoint URL, and region name.

from s3minimal import S3

s3 = S3(
    endpoint_url="https://s3.amazonaws.com",
    region_name="us-east-1",
    aws_access_key_id="your_access_key",
    aws_secret_access_key="your_secret_key",
)

# or if you have environment variables set for your AWS credentials
s3 = S3()

For synchronous operations, you can use the S3Sync class in a similar manner, and all asynchronous methods described below can be called without await.

Set Bucket

s3.set_bucket("your_bucket_name")

Download File

file = await s3.download("path/to/your/file")

Upload File

with open("path/to/your/local/file", "rb") as f:
    file_obj = io.BytesIO(f.read())

await s3.upload("path/to/your/s3/file", file_obj)

Move File

await s3.move("path/to/source/file", "path/to/destination/file")

Generate Presigned URL

url = await s3.generate_presigned_url("path/to/your/file")

Create Bucket

Create a new S3 bucket:

await s3.create_bucket("new_bucket_name")

To set CORS configurations during bucket creation, pass the set_cors parameter as True and provide the cors_configuration:

cors_configuration = {
    "CORSRules": [
        {
            "AllowedHeaders": ["Access-Control-Allow-Origin", "*"],
            "AllowedMethods": ["GET", "PUT", "POST", "DELETE", "HEAD"],
            "AllowedOrigins": ["*"],
            "MaxAgeSeconds": 60,
        }
    ]
}

await s3.create_bucket("new_bucket_name", set_cors=True, cors_configuration=cors_configuration)

List Files

files = await s3.list_files("path/in/your/bucket")

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Project details


Download files

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

Source Distribution

s3minimal-0.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

s3minimal-0.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file s3minimal-0.2.tar.gz.

File metadata

  • Download URL: s3minimal-0.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.5 Darwin/23.0.0

File hashes

Hashes for s3minimal-0.2.tar.gz
Algorithm Hash digest
SHA256 3b479a23ae13f83af0c49eb8bf6b5a9f01cbfadd516f5a8abf52d2d9e27ba7f0
MD5 b63ce5ea3d88e53158e8ea00d5dddf52
BLAKE2b-256 9b4ca66d70c84ca433ed374c0069a55fab4db24d5ddbb723d4b0f35351c0a77e

See more details on using hashes here.

File details

Details for the file s3minimal-0.2-py3-none-any.whl.

File metadata

  • Download URL: s3minimal-0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.5 Darwin/23.0.0

File hashes

Hashes for s3minimal-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec9ce9da90a1efe1163a2379dd44c8e3f9c776887d587051153c8a802da4f7ed
MD5 eb145fc21b21323483550c8448d1c295
BLAKE2b-256 f276f6759a5b7edcc797876ebb82260d4355d3194fbfa760662dc754ba94f092

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