IAttachmentStore
AgentPrism.Abstractions.dllThe contract for attachment metadata and for the default (database) content storage.
public interface IAttachmentStoreRemarks
Section titled “Remarks”When IAttachmentStorage is registered the content lives there and this
store keeps the metadata only; when it is not registered the content is stored
directly in the database (bytea).
Methods
Section titled “Methods”DeleteAsync(string, Guid, CancellationToken)
Section titled “ DeleteAsync(string, Guid, CancellationToken)”Deletes an attachment.
ValueTask<bool> DeleteAsync(string tenantId, Guid id, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant id.
id Guid
The attachment id.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true when a record was deleted.
DeleteBySessionAsync(string, string, CancellationToken)
Section titled “ DeleteBySessionAsync(string, string, CancellationToken)”Deletes every attachment of a session.
ValueTask<int> DeleteBySessionAsync(string tenantId, string sessionId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant id.
sessionId string
The session id.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The number of records deleted.
Remarks
Section titled “Remarks”It is called when a session is deleted; it keeps orphaned attachments from piling up.
GetAsync(string, Guid, CancellationToken)
Section titled “ GetAsync(string, Guid, CancellationToken)”Reads the metadata of a single attachment.
ValueTask<AttachmentDescriptor?> GetAsync(string tenantId, Guid id, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant id.
id Guid
The attachment id.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<AttachmentDescriptor?>
The record, or null when it does not exist or belongs to another tenant.
ListAsync(AttachmentQuery, CancellationToken)
Section titled “ ListAsync(AttachmentQuery, CancellationToken)”Lists the attachments through a filter.
ValueTask<IReadOnlyList<AttachmentDescriptor>> ListAsync(AttachmentQuery query, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”query AttachmentQuery
The filter.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<AttachmentDescriptor>>
The records ordered from newest to oldest.
OpenReadAsync(string, Guid, CancellationToken)
Section titled “ OpenReadAsync(string, Guid, CancellationToken)”Opens the raw content of an attachment as a stream.
ValueTask<Stream?> OpenReadAsync(string tenantId, Guid id, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant id.
id Guid
The attachment id.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”A readable stream, or null when the record does not exist or belongs to another tenant.
SaveAsync(AttachmentContent, CancellationToken)
Section titled “ SaveAsync(AttachmentContent, CancellationToken)”Saves a new attachment.
ValueTask<AttachmentDescriptor> SaveAsync(AttachmentContent content, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”content AttachmentContent
The content and metadata to save.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<AttachmentDescriptor>
The attachment record with its id and digest assigned.