Skip to main content

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.


This `README.md` includes:

- Installation instructions  
- Environment variables usage  
- Full example for **upload, download, move, copy, delete, folders, and pre-signed URL**  
- MIT License section  

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

s3managerpy-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s3managerpy-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file s3managerpy-0.1.0.tar.gz.

File metadata

  • Download URL: s3managerpy-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for s3managerpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8893c07e2cd18add14cea8ff1786d87498c7d79c48f298e6548bbc268e767c7d
MD5 356155c30dd918896b0f8fbd2db6c9dd
BLAKE2b-256 6547dd9503b382da8d22b24a65151e3481003fa7fce13063b8df008737925500

See more details on using hashes here.

File details

Details for the file s3managerpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: s3managerpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for s3managerpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97f8e45e8e2397706817600c49e9c94770d82d070b1511d40b8667fb944f2640
MD5 c70c540d2f49b25c876e8d84fb93b37a
BLAKE2b-256 f614104fac46a9552849219d51ecfea2d78c015a0fa2c6811bd39d7448725042

See more details on using hashes here.

Supported by

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