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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file s3minimal-0.1.7.tar.gz
.
File metadata
- Download URL: s3minimal-0.1.7.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | daccd3b10649552f2ee4839416d7634f6f6e8b29528d8cfd1379e3e8065d4d0f |
|
MD5 | e73e6f66a6bea29c45454805090a0ec8 |
|
BLAKE2b-256 | b2f6a8303e0958e3f006adadcc5910af8730f12d9a38f39080cd7dd298bdd5c9 |
File details
Details for the file s3minimal-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: s3minimal-0.1.7-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44bf4cebdbd3174d1e26628a30a930d5e68c074a5a0492dd8168eadd698f4e6d |
|
MD5 | 72d6be466bb6e9ae5f017de10c919326 |
|
BLAKE2b-256 | edf073e48e692fa8f1a9e764d5b5a76c1b86d693c071f77c25d2c568fc35d7d7 |