Skip to content
Tracon

IAttachmentStorage

Namespace Tracon · Assembly Tracon.Abstractions.dll

The extension point that stores attachment content in an external store (S3, Blob).

public interface IAttachmentStorage

When it is not registered the content lives in the database, so nothing has to be set up first. Tracon takes no dependency on any cloud SDK; the consumer writes the implementation.

DI lifetime — singleton, optional. No default implementation is registered. A consumer that registers one must register it as a singleton (or hand it to IServiceProvider.GetService<IAttachmentStorage>’s caller, itself resolved once as a singleton dependency, for example InMemoryAttachmentStore) — never scoped, which would be a captive dependency.

Deletes the content in the external store.

ValueTask DeleteAsync(Uri uri, CancellationToken cancellationToken = default)

uri Uri

The location returned by IAttachmentStorage.WriteAsync.

cancellationToken CancellationToken

The cancellation token.

ValueTask

A task that completes when the content is gone.

Must be idempotent. Deleting a location that no longer exists succeeds and does not throw. Tracon deletes the content BEFORE the metadata row, so a retry after a partial failure — or two deletes that race — calls this method again for content that is already gone.

Throw only when the content may still exist. The attachment store, the retention policy, and data subject erasure then keep the metadata row, because it is the only record of where the content is: a single delete and an erasure fail, and retention retries the row on its next run.

Reads the content from the external store.

ValueTask<Stream?> ReadAsync(Uri uri, CancellationToken cancellationToken = default)

uri Uri

The location returned by IAttachmentStorage.WriteAsync.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Stream?>

A readable stream, or null when the location no longer exists.

Stream ownership. The CALLER owns the returned stream and must dispose it.

WriteAsync(string, Guid, Stream, string, CancellationToken)

Section titled “ WriteAsync(string, Guid, Stream, string, CancellationToken)”

Writes the content to the external store.

ValueTask<Uri> WriteAsync(string tenantId, Guid id, Stream content, string mediaType, CancellationToken cancellationToken = default)

tenantId string

The tenant id.

id Guid

The attachment id.

content Stream

The content to write.

mediaType string

The MIME type of the content.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Uri>

The location of the content in the external store.

Stream ownership. The CALLER owns content and disposes it; this method reads from it but does not dispose it.