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. Defaults to attachments.
attachmentTableName?stringThe name of the table where attachments are stored, defaults to attachments table.
cacheLimit?numberHow many attachments to keep in the cache
downloadAttachments?booleanShould attachments be downloaded
onDownloadError?(attachment, exception) => Promise<{ retry?: boolean; }>How to handle download errors, return { retry: false } to ignore the download
onUploadError?(attachment, exception) => 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
powersyncCommonPowerSyncDatabase-
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<ResolvedTableOptions, "name" | "columns">

Properties​

PropertyTypeDescriptionInherited from
additionalColumns?Column[]--
direct?booleanAlpha Marks this table as direct, meaning that it stores data directly as SQLite rows instead of using an intermediate view around a JSON store. Direct tables are still managed by the PowerSync SDK, which is responsible for creating, altering and dropping them. You can query direct tables like JSON-based tables, and mutations are consistently tracked as pending uploads. For more information on direct tables, see the documentation. Direct tables can't use a ResolvedTableOptions.viewName. Direct tables are currently experimental.Omit.direct
ignoreEmptyUpdates?boolean-Omit.ignoreEmptyUpdates
indexes?Index[]-Omit.indexes
insertOnly?boolean-Omit.insertOnly
localOnly?boolean-Omit.localOnly
name?string--
trackMetadata?boolean-Omit.trackMetadata
trackPrevious?boolean | TrackPreviousOptions-Omit.trackPrevious
viewName?string-Omit.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?{ filename?: string; }
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?{ encoding?: EncodingType; mediaType?: string; }
options.encoding?EncodingType
options.mediaType?string
Returns​

Promise<ArrayBuffer>

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

Promise<void>

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

Promise<void>

Variables​

ATTACHMENT_TABLE​

const ATTACHMENT_TABLE: "attachments" = 'attachments';

DEFAULT_ATTACHMENT_QUEUE_OPTIONS​

const DEFAULT_ATTACHMENT_QUEUE_OPTIONS: {
attachmentDirectoryName: string;
attachmentTableName: string;
cacheLimit: number;
downloadAttachments: true;
performInitialSync: true;
syncInterval: number;
};

Type Declaration​

NameTypeDefault value
attachmentDirectoryNamestringATTACHMENT_TABLE
attachmentTableNamestringATTACHMENT_TABLE
cacheLimitnumber100
downloadAttachmentstruetrue
performInitialSynctruetrue
syncIntervalnumber30_000