AttachmentQueue class base attachments

Class used to implement the attachment queue.

Manages the lifecycle of attachment records, including watching for new attachments, syncing with remote storage, handling uploads, downloads, and deletes, and managing local storage.

Annotations
  • @experimental

Constructors

AttachmentQueue.new({required PowerSyncDatabase db, required RemoteStorage remoteStorage, required Stream<List<WatchedAttachmentItem>> watchAttachments(), required LocalStorage localStorage, String attachmentsQueueTableName = AttachmentsQueueTable.defaultTableName, AttachmentErrorHandler? errorHandler, Duration syncInterval = const Duration(seconds: 30), int archivedCacheLimit = 100, Duration syncThrottleDuration = const Duration(seconds: 1), bool downloadAttachments = true, Logger? logger})
Creates a new attachment queue.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearQueue() Future<void>
Clears the attachment queue and deletes all attachment files.
close() Future<void>
Closes the queue. The queue cannot be used after closing.
deleteFile({required String attachmentId, required Future<void> updateHook(SqliteWriteContext context, Attachment attachment)}) Future<Attachment>
Queues an attachment for delete. The default implementation assumes the attachment record already exists locally.
expireCache() Future<void>
Removes all archived items.
generateAttachmentId() Future<String>
Generates a random attachment id.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolveNewAttachmentFilename(String attachmentId, String? fileExtension) Future<String>
Resolves the filename for new attachment items. Concatenates the attachment ID and extension by default.
saveFile({required Stream<List<int>> data, required String mediaType, String? fileExtension, String? metaData, String? id, required Future<void> updateHook(SqliteWriteContext context, Attachment attachment)}) Future<Attachment>
Creates a new attachment locally and queues it for upload. The filename is resolved using resolveNewAttachmentFilename.
startSync() Future<void>
Initialize the attachment queue by:
stopSyncing() Future<void>
Stops syncing. Syncing may be resumed with startSync.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited