ZyncAttachmentManager

Manager class for handling attachment operations. Provides offline-first attachment management with automatic sync capabilities.

Functions

Link copied to clipboard
suspend fun addAttachment(filePath: String, attachmentName: String, module: String, moduleUid: String, type: ZyncAttachmentType, description: String?, tagUids: List<String>?, latitude: Double?, longitude: Double?): AttachmentOperationResult

Add a new attachment to the system. This method reads the file from the provided path, copies it to the app-specific directory, calculates its hash, and stores the attachment information in the database.

Link copied to clipboard
suspend fun deleteAttachment(attachmentUid: String): ZyncResult

Delete an attachment. This will also remove the physical file from storage.

Link copied to clipboard
suspend fun deleteAttachments(attachmentUids: List<String>): ZyncResult

Delete multiple attachments in a single operation. Each attachment will be marked as deleted and its physical file removed if possible.

Link copied to clipboard
suspend fun getAttachment(attachmentUid: String): AttachmentGetResult

Get an attachment by its UID.

Link copied to clipboard
suspend fun getAttachments(module: ZuperModule, moduleUid: String, page: Int, pageSize: Int, filters: ZyncAttachmentFilters? = null): AttachmentResult

Get paginated attachments with simple result-based API. Client handles loading states externally.

Link copied to clipboard
suspend fun getAttachmentsGroupedByDate(module: ZuperModule, moduleUid: String, page: Int, pageSize: Int, filters: ZyncAttachmentFilters? = null): AttachmentGroupResult

Get paginated attachments grouped by date with simple result-based API. Client handles loading states externally.

Link copied to clipboard
suspend fun getTagsByModuleUid(moduleUid: String, searchQuery: String? = null): MasterTagsResult

Get all unique tags associated with attachments for a specific module UID. This method queries all attachments matching the provided module UID and returns the distinct tags that are associated with those attachments.

Link copied to clipboard

Validates that a file URI has a valid scheme and format.

Link copied to clipboard

Observe attachment changes and upload progress for a specific module and module UID. The subscription remains active while the returned Flow is collected.

Link copied to clipboard
suspend fun removeTag(attachmentUid: String, tagUid: String): ZyncResult

Remove a tag from an existing attachment. This removes the relationship between the attachment and tag, queuing the operation for sync.

Link copied to clipboard
suspend fun renameAttachment(attachmentUid: String, newName: String): AttachmentOperationResult

Rename an existing attachment.

Link copied to clipboard
suspend fun updateAttachmentDescription(attachmentUid: String, newDescription: String): AttachmentOperationResult

Update the description of an attachment.

Link copied to clipboard
suspend fun updateAttachmentFile(attachmentUid: String, newFilePath: String, latitude: Double?, longitude: Double?): AttachmentOperationResult

Update the image/file of an attachment. This method reads the new file, calculates its hash, and only copies it if the hash differs.

Link copied to clipboard
suspend fun updateAttachmentTags(attachmentUid: String, tags: List<String>): ZyncResult
Link copied to clipboard
suspend fun uploadAttachmentImmediately(filePath: ZyncFile, module: String, moduleUid: String, attachmentType: ZyncAttachmentType = ZyncAttachmentType.Attachment): UploadAttachmentResult

Upload a single attachment immediately, bypassing the regular upload queue. This method stops any current upload work, uploads the specified file, and then resumes normal upload operations.

Link copied to clipboard
suspend fun uploadAttachmentsImmediately(filePaths: List<ZyncFile>, module: String, moduleUid: String, attachmentType: ZyncAttachmentType): UploadAttachmentsResult

Upload attachments immediately, bypassing the regular upload queue. This method stops any current upload work, uploads the specified files, and then resumes normal upload operations.