Python S3 Utils
Overview
Wrapper around boto3 functionality for common interactions with S3. It may be a bit overkill, but there are some minor quality of life improvements.
Installation
Install Python S3 Utils:
python3 -m pip install python-s3-utils
Usage
import boto3
from s3_utils import S3Bucket
session = boto3.session.Session(
aws_access_key_id="AWS_ACCESS_KEY_ID",
aws_secret_access_key="AWS_SECRET_ACCESS_KEY",
)
s3bucket = S3Bucket(session, "bucket-name")
# Returns True/False
s3bucket.file_exists('key-name')
# Returns a generator of all objects in the bucket, does not have a 1000 object limit like `list_objects`
s3bucket.list_objects_recursive()
# File name becomes the key name if key_name not provided
s3bucket.upload_file("path/filename.jpg", key_name=None)
# Upload all files in a directory
s3bucket.upload_files("path/")
# File would be downloaded to target_dir/prefix/filename.jpg
s3bucket.download_file("prefix/filename.jpg", "target_dir")
# Returns a dict summary of the operation
s3bucket.delete_files(["path/filename.jpg", "key-name"])
Development
To get a list of all commands with descriptions simply run make.
make env
make pip_install
make pip_install_editable
Testing
make pytest
make coverage
make open_coverage
Issues
If you experience any issues, please create an issue on GitHub.
History
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
0.1.0 (2024-05-14)
- First release
Metadata
Release files for python-s3-utils 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_s3_utils-0.1.0.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_s3_utils-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.0 kB
Release files / python_s3_utils-0.1.0.tar.gz
| Download URL | python_s3_utils-0.1.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a82e29d9bc930ed0a7ba0dbc76a4d78b96cf5a51439525704d979949304f882d
|
|
BLAKE2b-256 checksum How to use checksums |
5322f2a8aa27ee6d2b5e7a70cd95473ea407c4a733d96a6a21409dd5f596950d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.11
|
Release files / python_s3_utils-0.1.0-py3-none-any.whl
| Download URL | python_s3_utils-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8238b79026f3c61d343665a9bd3f05f55e4896bbf6c32d0b0a8b7581f8a73855
|
|
BLAKE2b-256 checksum How to use checksums |
0f2ee7f36709423fef080a2a4b6565222d94fc67746b37ce05404f76ddddf440
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.11
|