FastAPI Storage
Introduction
FastAPI Storage provides helper functions for interacting with AWS S3, making it easier to handle file storage, presigned URLs, metadata, and content-type modifications
How to use
Configuration
First, configure the storage service by setting up AWS credentials and bucket information:
# config/storage.py
from fastapi_storage_helper import StorageService
from config.setting import env
storage_service = StorageService(
access_key_id=env.AWS_ACCESS_KEY_ID,
secret_key=env.AWS_SECRET_KEY,
region_name=env.AWS_REGION,
bucket=env.AWS_S3_BUCKET_NAME,
)
Create Read Presign URL
To generate a presigned URL for reading a file from S3:
from config.storage import storage_service
def get_media_url(self, s3_image_path: str):
return storage_service.create_read_presign_url(s3_image_path)
Create an Upload Presign URL
To generate a presigned URL for uploading a file to S3:
from config.storage import storage_service
def get_upload_media_url(self, s3_image_path: str):
return storage_service.create_upload_presign_url(s3_image_path)
Upload file to S3
To directly upload a file to an S3 bucket:
from config.storage import storage_service
def upload_file(self, file: bytes, s3_image_path: str):
return storage_service.upload_file(file, s3_image_path)
Get metadata
To get metadata for a file stored in S3:
from config.storage import storage_service
def get_metadata(self, s3_image_path: str):
return storage_service.get_metadata(s3_image_path)
Change Content Type
To modify the content type of a file in S3:
from config.storage import storage_service
def change_content_type(self, s3_image_path: str, content_type: str):
return storage_service.change_content_type(s3_image_path, content_type)
Metadata
Release files for fastapi-storage-helper 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_storage_helper-0.0.11.tar.gz | 5.0 kB | Without provenance | Details for fastapi_storage_helper-0.0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_storage_helper-0.0.11-py3-none-any.whl | Python 3 | none | any | Details for fastapi_storage_helper-0.0.11-py3-none-any.whl |
Total release size: 8.2 kB
Release files / fastapi_storage_helper-0.0.11.tar.gz
| Download URL | fastapi_storage_helper-0.0.11.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d9b207f8e40d267be16ccb6be4e0087fddbbe471fdaeb55a66e400622882adb
|
|
BLAKE2b-256 checksum How to use checksums |
3fc1cd4222039d2ab1f9f5bea6b57e9a05cf699b3666f1ca5faac7b5ea0c85f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|
Release files / fastapi_storage_helper-0.0.11-py3-none-any.whl
| Download URL | fastapi_storage_helper-0.0.11-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64d5f932c0c9ad174ec9367cb22e2ed405afa8952e1423b6db5a0233db80dc81
|
|
BLAKE2b-256 checksum How to use checksums |
a28bff151bb5524790f5abcc3a4eb5a508fda0fde0f3f18d6c0102386261f38e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|
Security for fastapi-storage-helper 0.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.