Skip to main content

vintasend-aws-s3-attachments

An AWS S3 attachment manager for vintasend, backed by boto3.

VintaSend splits an attachment into two things: the bytes, owned by an attachment manager, and a row describing them, owned by a notification backend. This package is the manager half: it stores every uploaded file as an object in an S3 bucket and hands the backend an opaque storage_identifiers dict so the backend never has to talk to S3 itself. Pair it with any vintasend backend that supports attachments (vintasend-django, vintasend-sqlalchemy, ...).

Install

poetry add vintasend-aws-s3-attachments
# or
pip install vintasend-aws-s3-attachments

boto3 comes as a dependency. AWS credentials and region are resolved the usual boto3 way (environment variables, ~/.aws/, an instance role, ...), unless you inject a preconfigured client.

Usage

from vintasend.services.notification_service import NotificationService
from vintasend_aws_s3_attachments import S3AttachmentManager

service = NotificationService(
    notification_adapters=[...],
    notification_backend=my_backend,           # any attachment-aware vintasend backend
    attachment_manager=S3AttachmentManager(
        bucket="my-notification-attachments",
        prefix="attachments",                  # optional key prefix ("folder")
    ),
)

Instead of passing an instance, you can point the NOTIFICATION_ATTACHMENT_MANAGER setting at a dotted path and let the service resolve it.

Configuring the S3 client

The manager builds boto3.client("s3") lazily on first use. Steer that with client_kwargs:

S3AttachmentManager(
    bucket="my-bucket",
    client_kwargs={"region_name": "eu-west-1", "endpoint_url": "https://minio.local"},
)

Or inject a client you already built (a shared session, a MinIO/LocalStack endpoint, a custom retry config, and so on):

import boto3

S3AttachmentManager(bucket="my-bucket", client=boto3.client("s3"))

AsyncIO

S3AsyncIOAttachmentManager has the same constructor and mirrors the sync class for AsyncIONotificationService. boto3 is synchronous, so upload_file / delete_file_by_identifiers are async def that wrap boto3's blocking calls; reconstruct_attachment_file stays a plain method (it only builds a lazy handle, doing no I/O), matching the base seam.

How storage identifiers work

upload_file writes the object under a collision-free key (<prefix>/<uuid>_<filename>) and returns an AttachmentFileRecord whose storage_identifiers is:

{"id": key, "bucket": bucket, "key": key}

id is the required, non-empty key every manager must provide; bucket and key are what this manager reads back in reconstruct_attachment_file / delete_file_by_identifiers. A record written without a bucket key (a legacy row) still resolves against the manager's own configured bucket.

The handle returned by reconstruct_attachment_file is an S3StoredFile:

  • read() / stream() fetch the object (a missing object raises FileNotFoundError),
  • url(expires_in=3600) returns a presigned GET URL,
  • delete() removes the object.

Reclaiming orphaned files

VintaSend never deletes stored bytes on its own. To reclaim files no notification references anymore, drive the backend's orphan query and this manager together in a periodic task of your own:

for record in backend.get_orphaned_attachment_files():
    manager.delete_file_by_identifiers(record.storage_identifiers)  # delete the S3 object
    backend.delete_attachment_file(record.id)                       # drop the row

Development

poetry install
poetry run pytest   # tests run fully offline against an in-memory fake S3 client
poetry run ruff check
poetry run mypy

The test suite injects a fake boto3-style client, so no AWS account, credentials, or network access are needed to run it.

Metadata

Release files for vintasend-aws-s3-attachments 3.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vintasend-aws-s3-attachments 3.8.0
File Size Uploaded Provenance Actions
vintasend_aws_s3_attachments-3.8.0.tar.gz 6.5 kB With provenance Details for vintasend_aws_s3_attachments-3.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vintasend-aws-s3-attachments 3.8.0
File Interpreter ABI Platform Actions
vintasend_aws_s3_attachments-3.8.0-py3-none-any.whl Python 3 none any Details for vintasend_aws_s3_attachments-3.8.0-py3-none-any.whl

Total release size: 12.9 kB

Release files / vintasend_aws_s3_attachments-3.8.0.tar.gz

Download URL vintasend_aws_s3_attachments-3.8.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
97d9c58e3f9b03730f21e1b2f3a3e45dfd159d305d0fcc923f98a1587a6e7e52
BLAKE2b-256 checksum
How to use checksums
e444c5ba69b2384f69edfca65c520506e364dd73b51e229757bf25e63359faf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / vintasend_aws_s3_attachments-3.8.0-py3-none-any.whl

Download URL vintasend_aws_s3_attachments-3.8.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df093fa14ef7a4af6aa9d65d3ad3e21a0c33a391b8f7f7ccd2f504102fa80aa6
BLAKE2b-256 checksum
How to use checksums
2d53b34d5fc52751129117039f2f8bb5ccb0a8c8bd5cde9e6a6313941caa6290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for vintasend-aws-s3-attachments 3.8.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vintasend_aws_s3_attachments-3.8.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page