RSE standard file storage helpers with Vault-backed configuration and GCS support.
Project description
rse-files-core
RSE standard file storage package for Python APIs.
Features:
- GCS upload/download helpers
- storage configuration from local environment or HashiCorp Vault
- filename and storage key sanitization
- SHA-256 checksums
- PDF/content-type/max-size validation
- standardized metadata and exceptions
Usage
from rse_files import (
build_storage_key,
create_file_storage,
validate_pdf_bytes,
)
storage = create_file_storage()
validate_pdf_bytes(content)
storage_key = build_storage_key(
namespace="nc",
owner_type="action-plan-evidence",
owner_id=123,
filename="evidencia.pdf",
)
metadata = storage.upload_bytes(
content=content,
storage_key=storage_key,
content_type="application/pdf",
filename="evidencia.pdf",
)
public_url = storage.get_public_url(storage_key)
get_public_url only builds the canonical public GCS URL for a valid storage key.
It does not change bucket IAM, object ACLs, signed URL settings, or CDN settings.
Public access must be configured explicitly in the target bucket infrastructure.
Local Configuration
When RSE_ENV=local, the package reads regular environment variables:
RSE_FILES_STORAGE_PROVIDER=gcs
RSE_FILES_BUCKET=my-bucket
RSE_FILES_PREFIX=uploads
Vault
When RSE_ENV is stg or prd, the package reads Vault using:
RSE_ENVas the KV v2 mount pointRSE_VAULT_HOSTas the Vault URLRSE_VAULT_TOKENas the Vault tokenRSE_FILES_VAULT_PATHas the secret path, defaulting toshared
Expected keys:
rse_files_storage_provider
rse_files_bucket
rse_files_prefix
Fallback keys are also accepted for compatibility:
document_storage_provider
gcs_documents_bucket
gcs_documents_prefix
Example:
stg/shared.rse_files_storage_provider = gcs
stg/shared.rse_files_bucket = rse-documents-stg
stg/shared.rse_files_prefix = files
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 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 rse_files_core-0.2.1.tar.gz.
File metadata
- Download URL: rse_files_core-0.2.1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e8f7c68519cf18622641af08b629d3ebe016f21eea63d976328167f4a089437
|
|
| MD5 |
ebf0a6ea265ed908ce228c2d6e1d1115
|
|
| BLAKE2b-256 |
32cd029b79cd63b721d22ea352dfb0001ab27a0ef9f95690454b0c5802a9975a
|
File details
Details for the file rse_files_core-0.2.1-py3-none-any.whl.
File metadata
- Download URL: rse_files_core-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6c9be2a6e32e8cba2db2ff31b35160078418394b1310a54cd824bbc39f44bd5
|
|
| MD5 |
244fd75a823c5f71572bbc4427e4a07a
|
|
| BLAKE2b-256 |
e9a85b1edd8ce772da5e946fa0cd3856f4d053193fa6bb95bc26ce4d9b1da4fd
|