Skip to main content

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_ENV as the KV v2 mount point
  • RSE_VAULT_HOST as the Vault URL
  • RSE_VAULT_TOKEN as the Vault token
  • RSE_FILES_VAULT_PATH as the secret path, defaulting to shared

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

rse_files_core-0.2.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

rse_files_core-0.2.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file rse_files_core-0.2.2.tar.gz.

File metadata

  • Download URL: rse_files_core-0.2.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.0 Windows/10

File hashes

Hashes for rse_files_core-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0973556cc5be7bab9c34e4c8d6cd052a43d1d82dc34921fe9bc4dcf043051e31
MD5 23ac0dad7dc58e4f9bd163318c456750
BLAKE2b-256 7659fed47b616ca889fa6fe3ff44aae84fd76d20bf816386781298467f0e0652

See more details on using hashes here.

File details

Details for the file rse_files_core-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: rse_files_core-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.0 Windows/10

File hashes

Hashes for rse_files_core-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6482966a55cb8296d8b1eeb82b4538d28e74fb89213911e4c096316523824904
MD5 57f5783cbe7d68c266ae94d4112af77c
BLAKE2b-256 f63c1fbad4eb0068b6520b89b93cbb51ddd1bf918e7a0cb144bbbc9a7a242afc

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