@powersync/attachments
Enumerations
| Enumeration | Description |
|---|---|
| AttachmentState | - |
| EncodingType | - |
Classes
| Class | Description |
|---|---|
| AbstractAttachmentQueue | - |
| AttachmentTable | - |
Interfaces
AttachmentQueueOptions
Properties
| Property | Type | Description |
|---|---|---|
attachmentDirectoryName? | string | The name of the directory where attachments are stored on the device, not the full path. Defaults to attachments. |
attachmentTableName? | string | The name of the table where attachments are stored, defaults to attachments table. |
cacheLimit? | number | How many attachments to keep in the cache |
downloadAttachments? | boolean | Should attachments be downloaded |
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? | boolean | Whether to mark the initial watched attachment IDs to be synced |
powersync | AbstractPowerSyncDatabase | - |
storage | StorageAdapter | - |
syncInterval? | number | How often to check for new attachments to sync, in milliseconds. Set to 0 or undefined to disable. |
AttachmentRecord
Properties
| Property | Type |
|---|---|
filename | string |
id | string |
local_uri? | string |
media_type? | string |
size? | number |
state | AttachmentState |
timestamp? | number |
AttachmentTableOptions
Extends
Omit<TableOptions,"name"|"columns">
Properties
StorageAdapter
Methods
copyFile()
copyFile(sourceUri, targetUri): Promise<void>
Parameters
| Parameter | Type |
|---|---|
sourceUri | string |
targetUri | string |
Returns
Promise<void>
deleteFile()
deleteFile(uri, options?): Promise<void>
Parameters
| Parameter | Type |
|---|---|
uri | string |
options? | { filename: string; } |
options.filename? | string |
Returns
Promise<void>
downloadFile()
downloadFile(filePath): Promise<Blob>
Parameters
| Parameter | Type |
|---|---|
filePath | string |
Returns
Promise<Blob>
fileExists()
fileExists(fileUri): Promise<boolean>
Parameters
| Parameter | Type |
|---|---|
fileUri | string |
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
| Parameter | Type |
|---|---|
uri | string |
Returns
Promise<void>
readFile()
readFile(fileUri, options?): Promise<ArrayBuffer>
Parameters
| Parameter | Type |
|---|---|
fileUri | string |
options? | { encoding: EncodingType; mediaType: string; } |
options.encoding? | EncodingType |
options.mediaType? | string |
Returns
Promise<ArrayBuffer>
uploadFile()
uploadFile(
filePath,
data,
options?): Promise<void>
Parameters
| Parameter | Type |
|---|---|
filePath | string |
data | ArrayBuffer |
options? | { mediaType: string; } |
options.mediaType? | string |
Returns
Promise<void>
writeFile()
writeFile(
fileUri,
base64Data,
options?): Promise<void>
Parameters
| Parameter | Type |
|---|---|
fileUri | string |
base64Data | string |
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: Partial<AttachmentQueueOptions>;