A clean helper class to manage AWS S3 operations in Python.
Project description
S3ManagerPy
A clean, reusable Python package for managing AWS S3 operations, designed to simplify file and folder management in Python projects. Works seamlessly with Django, Flask, FastAPI, or plain Python.
Features
- Upload images and documents
- Download files (to disk or bytes)
- Copy, move, and delete files
- List folders or files
- Check if a file exists
- Generate pre-signed URLs
- Create folders (prefixes)
Installation
pip install s3managerpy
## Environment Variables
The package can load AWS credentials from environment variables:
AWS_BUCKET_NAME – Your S3 bucket name
AWS_REGION – AWS region (e.g., us-east-1)
AWS_ACCESS_KEY_ID – AWS access key
AWS_SECRET_ACCESS_KEY – AWS secret key
AWS_CLOUDFRONT_DOMAIN – Optional CloudFront domain for CDN URLs
You can also pass these values directly when initializing S3Manager.
Usage
from s3managerpy import S3Manager
# Initialize S3 manager
s3 = S3Manager()
# --------------------------
# Uploading files
# --------------------------
# Upload an image
url = s3.upload_image(file, "avatars", "john")
print("Uploaded image URL:", url)
# Upload a document
doc_url = s3.upload_file(file, "documents", "resume_2025")
print("Uploaded document URL:", doc_url)
# --------------------------
# Downloading files
# --------------------------
# Download a file from S3 to local disk
s3.download("documents/resume_2025.pdf", "resume.pdf")
# Download file as bytes
file_bytes = s3.download("documents/resume_2025.pdf")
print("Downloaded bytes:", len(file_bytes))
# --------------------------
# File operations
# --------------------------
# Check if a file exists
exists = s3.file_exists("avatars/john.jpg")
print("File exists:", exists)
# Copy a file
s3.copy_file("avatars/john.jpg", "avatars/john_backup.jpg")
# Move (rename) a file
s3.move_file("avatars/john_backup.jpg", "avatars/john_final.jpg")
# Delete a file
s3.delete_file("avatars/john_final.jpg")
# Delete all files in a folder
s3.delete_folder("documents/temp_folder")
# --------------------------
# Folder operations
# --------------------------
# Create a new folder
s3.create_folder("projects/demo")
# List folders and files
folders = s3.list_folders("projects/")
print("Folders:", folders)
files = s3.list_files("projects/demo")
print("Files:", files)
# --------------------------
# Pre-signed URL
# --------------------------
signed_url = s3.get_signed_url("documents/resume_2025.pdf", expires=600)
print("Temporary download URL:", signed_url)
License
MIT License. See LICENSE
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
s3managerpy-0.1.1.tar.gz
(5.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file s3managerpy-0.1.1.tar.gz.
File metadata
- Download URL: s3managerpy-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b2b82f93c1c39cd16fbcdac4fe444848221b6a3b9dae52fed9e37fd57ef3d72
|
|
| MD5 |
7dfcb5526555279eed569bb2b5a2e191
|
|
| BLAKE2b-256 |
77df457a1bb9f3a4d2f475b249150266980fad9dae86b8aa7e931c025f148eb6
|
File details
Details for the file s3managerpy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: s3managerpy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1ebc7c8bd243ee43d4f822a0992de386fb28ef431c00f6389b9839d63f4eac6
|
|
| MD5 |
445d6f1fa8e7f3b39c2946296b578eab
|
|
| BLAKE2b-256 |
73e4a429f05911563390d71ad60fdc920793dfe1eb4699a213d0e10b28477db9
|