Skip to main content

@powersync/attachments

Enumerations

EnumerationDescription
AttachmentState-
EncodingType-

Classes

ClassDescription
AbstractAttachmentQueue-
AttachmentTable-

Interfaces

AttachmentQueueOptions

Properties

PropertyTypeDescription
attachmentDirectoryName?stringThe name of the directory where attachments are stored on the device, not the full path
cacheLimit?numberHow many attachments to keep in the cache
onDownloadError?(attachment: AttachmentRecord, exception: any) => Promise<{ retry: boolean; }>How to handle download errors, return { retry: false } to ignore the download
onUploadError?(attachment: AttachmentRecord, exception: any) => Promise<{ retry: boolean; }>How to handle upload errors, return { retry: false } to ignore the upload
performInitialSync?booleanWhether to mark the initial watched attachment IDs to be synced
powersyncAbstractPowerSyncDatabase-
storageStorageAdapter-
syncInterval?numberHow often to check for new attachments to sync, in milliseconds. Set to 0 or undefined to disable.

AttachmentRecord

Properties

PropertyType
filenamestring
idstring
local_uri?string
media_type?string
size?number
stateAttachmentState
timestamp?number

AttachmentTableOptions

Extends

  • Omit<TableOptions, "name" | "columns">

Properties

PropertyTypeInherited from
additionalColumns?Column[]-
indexes?Index[]Omit.indexes
insertOnly?booleanOmit.insertOnly
localOnly?booleanOmit.localOnly
name?string-
viewName?stringOmit.viewName

StorageAdapter

Methods

copyFile()
copyFile(sourceUri, targetUri): Promise<void>
Parameters
ParameterType
sourceUristring
targetUristring
Returns

Promise<void>


deleteFile()
deleteFile(uri, options?): Promise<void>
Parameters
ParameterType
uristring
options?object
options.filename?string
Returns

Promise<void>


downloadFile()
downloadFile(filePath): Promise<Blob>
Parameters
ParameterType
filePathstring
Returns

Promise<Blob>


fileExists()
fileExists(fileUri): Promise<boolean>
Parameters
ParameterType
fileUristring
Returns

Promise<boolean>


getUserStorageDirectory()
getUserStorageDirectory(): string

Returns the directory where user data is stored. Should end with a '/'

Returns

string


makeDir()
makeDir(uri): Promise<void>
Parameters
ParameterType
uristring
Returns

Promise<void>


readFile()
readFile(fileUri, options?): Promise<ArrayBuffer>
Parameters
ParameterType
fileUristring
options?object
options.encoding?EncodingType
options.mediaType?string
Returns

Promise<ArrayBuffer>


uploadFile()
uploadFile(
filePath,
data,
options?): Promise<void>
Parameters
ParameterType
filePathstring
dataArrayBuffer
options?object
options.mediaType?string
Returns

Promise<void>


writeFile()
writeFile(
fileUri,
base64Data,
options?): Promise<void>
Parameters
ParameterType
fileUristring
base64Datastring
options?object
options.encoding?EncodingType
Returns

Promise<void>

Variables

ATTACHMENT_TABLE

const ATTACHMENT_TABLE: "attachments" = 'attachments';

DEFAULT_ATTACHMENT_QUEUE_OPTIONS

const DEFAULT_ATTACHMENT_QUEUE_OPTIONS: Partial<AttachmentQueueOptions>;