High-performance library for generating AWS S3 presigned URLs
Project description
libpresign
High-performance library for generating AWS S3 presigned URLs. Generate presigned URLs up to 160x faster than boto3.
Features
- 🚀 Lightning Fast: 5-160x faster than boto3 for presigned URL generation
- 🔐 Secure: Full AWS Signature Version 4 compliance
- 🌍 Compatible: Works with S3 and S3-compatible services (MinIO, Wasabi, etc.)
- 📦 Lightweight: Minimal dependencies, pure C++ implementation
- 🐍 Python Ready: Simple Python bindings with type hints
- 🧵 Thread Safe: Generate URLs concurrently without locks
- 💰 Cost Effective: Reduce compute costs with faster operations
Installation
pip install libpresign
Pre-built wheels are available for:
- Linux: x86_64, aarch64 (Python 3.8-3.13)
- macOS: x86_64, arm64 (Python 3.8-3.13)
- Windows: AMD64 (Python 3.8-3.13)
Quick Start
import libpresign
# Generate a presigned URL
url = libpresign.get(
access_key_id="AKIAIOSFODNN7EXAMPLE",
secret_access_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
region="us-east-1",
bucket="my-bucket",
key="path/to/file.jpg",
expires=3600 # URL valid for 1 hour
)
print(url)
# https://my-bucket.s3.us-east-1.amazonaws.com/path/to/file.jpg?X-Amz-Algorithm=...
Performance
Benchmark Results
Generate 10,000 presigned URLs:
| Library | Time (ms) | URLs/sec | Speedup |
|---|---|---|---|
| libpresign | 60 | 166,667 | 160x |
| boto3 | 9,600 | 1,042 | 1x |
Single URL generation:
| Library | Time (μs) | Memory |
|---|---|---|
| libpresign | 6 | 262 bytes |
| boto3 | 102 | 1.6 KB |
Usage Examples
Basic Usage
import libpresign
# Simple URL generation
url = libpresign.get(
access_key_id="your-access-key",
secret_access_key="your-secret-key",
region="us-east-1",
bucket="my-bucket",
key="document.pdf"
)
Custom Endpoint (MinIO/S3-Compatible)
# Use with MinIO or other S3-compatible storage
url = libpresign.get(
access_key_id="minioadmin",
secret_access_key="minioadmin",
region="us-east-1",
bucket="my-bucket",
key="file.txt",
expires=3600,
endpoint="https://minio.example.com"
)
Batch Generation
# Generate multiple URLs efficiently
config = {
"access_key_id": "your-access-key",
"secret_access_key": "your-secret-key",
"region": "us-west-2",
"bucket": "my-bucket",
"expires": 3600
}
urls = []
for i in range(1000):
url = libpresign.get(**config, key=f"file_{i}.jpg")
urls.append(url)
Integration with Web Frameworks
FastAPI
from fastapi import FastAPI
import libpresign
app = FastAPI()
@app.get("/presigned-url")
async def get_presigned_url(file_key: str):
url = libpresign.get(
access_key_id="...",
secret_access_key="...",
region="us-east-1",
bucket="uploads",
key=file_key,
expires=3600
)
return {"url": url}
Django
from django.http import JsonResponse
import libpresign
def download_file(request, file_id):
url = libpresign.get(
access_key_id=settings.AWS_ACCESS_KEY_ID,
secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
region=settings.AWS_REGION,
bucket=settings.S3_BUCKET,
key=f"files/{file_id}",
expires=300 # 5 minutes
)
return JsonResponse({"download_url": url})
API Reference
libpresign.get()
Generate a presigned URL for S3 object access.
Parameters:
access_key_id(str): AWS access key IDsecret_access_key(str): AWS secret access keyregion(str | None): AWS region (defaults to "us-east-1")bucket(str): S3 bucket namekey(str): S3 object keyexpires(int): URL expiration time in seconds (defaults to 3600)endpoint(str | None): Custom S3 endpoint URL
Returns:
str: Presigned URL
Raises:
SystemError: If required parameters are invalid
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/myk0la-b/libpresign.git
cd libpresign
# Install uv package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in editable mode with dev dependencies
uv pip install -e ".[dev]"
Running Tests
# Run all tests with coverage
uv run pytest
# Run specific test file
uv run pytest tests/test_basic.py
# Run benchmarks
uv run pytest tests/test_benchmark_boto3.py -v
Code Quality
# Format code
uv run ruff format .
# Lint code
uv run ruff check .
# Type checking
uv run mypy libpresign
Building from Source
Prerequisites
- C++ compiler with C++11 support
- CMake 3.15+
- OpenSSL 3.x
- Python 3.8+
Build Instructions
# Quick build
pip install .
# Development build
pip install -e .
# Build wheel
pip wheel . --no-deps
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Reporting Issues
If you find a bug or have a feature request, please open an issue.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with OpenSSL for cryptographic operations
- Inspired by the need for faster S3 presigned URL generation
- Thanks to all contributors
Links
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
Built Distributions
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 libpresign-1.2.0.tar.gz.
File metadata
- Download URL: libpresign-1.2.0.tar.gz
- Upload date:
- Size: 61.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1448eb8c9aea00b5b439b2b9c1ce48b88bded5abc216498cab0fb9a8edb2ca84
|
|
| MD5 |
2a45d6c535af2b8fd8b99bbab261dff2
|
|
| BLAKE2b-256 |
8fcc45cf9ad3a64f5c080de2d5768594662cf685876dcb8f6913293ecd8a84e4
|
Provenance
The following attestation bundles were made for libpresign-1.2.0.tar.gz:
Publisher:
wheels.yml on myk0la-b/libpresign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libpresign-1.2.0.tar.gz -
Subject digest:
1448eb8c9aea00b5b439b2b9c1ce48b88bded5abc216498cab0fb9a8edb2ca84 - Sigstore transparency entry: 315945276
- Sigstore integration time:
-
Permalink:
myk0la-b/libpresign@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Branch / Tag:
refs/tags/v1.2.25 - Owner: https://github.com/myk0la-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Trigger Event:
release
-
Statement type:
File details
Details for the file libpresign-1.2.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: libpresign-1.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e75daa999490aff6301ad12bd09eba9755398175fee8cb6f016ae1b0d0337d4f
|
|
| MD5 |
0651641de1f4c69f86330afe851bd1c9
|
|
| BLAKE2b-256 |
17939410f77dad164ccd0b1c3a6631321e0348a457a79dfaac48dd32c4b94f08
|
Provenance
The following attestation bundles were made for libpresign-1.2.0-cp38-abi3-win_amd64.whl:
Publisher:
wheels.yml on myk0la-b/libpresign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libpresign-1.2.0-cp38-abi3-win_amd64.whl -
Subject digest:
e75daa999490aff6301ad12bd09eba9755398175fee8cb6f016ae1b0d0337d4f - Sigstore transparency entry: 315945290
- Sigstore integration time:
-
Permalink:
myk0la-b/libpresign@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Branch / Tag:
refs/tags/v1.2.25 - Owner: https://github.com/myk0la-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Trigger Event:
release
-
Statement type:
File details
Details for the file libpresign-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: libpresign-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a42bf6485b8719b7213ed1ba1b59489b512aca5cd4b378eb595816d620cd643f
|
|
| MD5 |
9f5c2a78a3a94b347dc01370a61e7471
|
|
| BLAKE2b-256 |
759de4d2e2c9d627f680d214b465f2500bd4104f0c1dec048703054079dc0184
|
Provenance
The following attestation bundles were made for libpresign-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
wheels.yml on myk0la-b/libpresign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libpresign-1.2.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
a42bf6485b8719b7213ed1ba1b59489b512aca5cd4b378eb595816d620cd643f - Sigstore transparency entry: 315945296
- Sigstore integration time:
-
Permalink:
myk0la-b/libpresign@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Branch / Tag:
refs/tags/v1.2.25 - Owner: https://github.com/myk0la-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Trigger Event:
release
-
Statement type:
File details
Details for the file libpresign-1.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: libpresign-1.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 890.4 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf11e7014e13f88a23307474ec178f305f93d0bc117b203de19acb9bb143e206
|
|
| MD5 |
47d4a5fd45e41e24d32ecc54c5773a51
|
|
| BLAKE2b-256 |
3dae670e1b1983a635e3f6271ad29e04826469c1291472e0915534f0f44f43a0
|
Provenance
The following attestation bundles were made for libpresign-1.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl:
Publisher:
wheels.yml on myk0la-b/libpresign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libpresign-1.2.0-cp38-abi3-manylinux2014_i686.manylinux_2_17_i686.whl -
Subject digest:
bf11e7014e13f88a23307474ec178f305f93d0bc117b203de19acb9bb143e206 - Sigstore transparency entry: 315945314
- Sigstore integration time:
-
Permalink:
myk0la-b/libpresign@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Branch / Tag:
refs/tags/v1.2.25 - Owner: https://github.com/myk0la-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Trigger Event:
release
-
Statement type:
File details
Details for the file libpresign-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: libpresign-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 901.6 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb6e40a472663ed354cd9037207bbad919b948b90fe878f049ef9fa23059d684
|
|
| MD5 |
0ec845c3306cb70ac8ba50f9372fedc4
|
|
| BLAKE2b-256 |
7caf1f84a73a69ecec6382bd0f4fc79848a18cdb2c4c3eb382260d53c5de6936
|
Provenance
The following attestation bundles were made for libpresign-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
wheels.yml on myk0la-b/libpresign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libpresign-1.2.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl -
Subject digest:
cb6e40a472663ed354cd9037207bbad919b948b90fe878f049ef9fa23059d684 - Sigstore transparency entry: 315945323
- Sigstore integration time:
-
Permalink:
myk0la-b/libpresign@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Branch / Tag:
refs/tags/v1.2.25 - Owner: https://github.com/myk0la-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Trigger Event:
release
-
Statement type:
File details
Details for the file libpresign-1.2.0-cp38-abi3-macosx_14_0_x86_64.whl.
File metadata
- Download URL: libpresign-1.2.0-cp38-abi3-macosx_14_0_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.8+, macOS 14.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b98a4e756700f6525a58d760981ae8dc700d7ce7b1226b05de1efac14aa676f9
|
|
| MD5 |
4b5afc26d793ca5228cd2955f9bf0aa4
|
|
| BLAKE2b-256 |
66e1f1e340ea2574d1b5d16d4609627fc57e0936a11b7983ca654bc23022854f
|
Provenance
The following attestation bundles were made for libpresign-1.2.0-cp38-abi3-macosx_14_0_x86_64.whl:
Publisher:
wheels.yml on myk0la-b/libpresign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libpresign-1.2.0-cp38-abi3-macosx_14_0_x86_64.whl -
Subject digest:
b98a4e756700f6525a58d760981ae8dc700d7ce7b1226b05de1efac14aa676f9 - Sigstore transparency entry: 315945306
- Sigstore integration time:
-
Permalink:
myk0la-b/libpresign@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Branch / Tag:
refs/tags/v1.2.25 - Owner: https://github.com/myk0la-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Trigger Event:
release
-
Statement type:
File details
Details for the file libpresign-1.2.0-cp38-abi3-macosx_14_0_arm64.whl.
File metadata
- Download URL: libpresign-1.2.0-cp38-abi3-macosx_14_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.8+, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7edacd9dfd6fbd52bc9f94a29a3f39b4d44a8d2c350ae7e021a763194f1f10a
|
|
| MD5 |
1329a211642370887766e456780ba304
|
|
| BLAKE2b-256 |
e2c371c26abf204a14aa539c2361f469c100540690e42e3fe0bf11457442394f
|
Provenance
The following attestation bundles were made for libpresign-1.2.0-cp38-abi3-macosx_14_0_arm64.whl:
Publisher:
wheels.yml on myk0la-b/libpresign
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libpresign-1.2.0-cp38-abi3-macosx_14_0_arm64.whl -
Subject digest:
c7edacd9dfd6fbd52bc9f94a29a3f39b4d44a8d2c350ae7e021a763194f1f10a - Sigstore transparency entry: 315945283
- Sigstore integration time:
-
Permalink:
myk0la-b/libpresign@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Branch / Tag:
refs/tags/v1.2.25 - Owner: https://github.com/myk0la-b
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@4aa4392a156855b15c9e7fff1fdb032e0236956b -
Trigger Event:
release
-
Statement type: