AttachmentsApi.data()
One attachment's bytes. Needs the
extract feature.methodReadingsince 1.0.0
Signature
data(index: number): Promise<Uint8Array>
Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | The attachment's index, as list() reports it. |
Returns
Promise<Uint8Array> The attachment's bytes.
Throws
INVALID_ARGUMENT— anindexthat names no attachment.PAGE_ERROR— the entry has no file stream, or the stream exceeds the SDK's size limit for an attachment.FEATURE_NOT_LICENSED— the license lacksextract.DOCUMENT_CLOSED— the document has been closed.
Example
TypeScript
const [first] = await doc.attachments.list(); if (first) { const bytes = await doc.attachments.data(first.index); saveAs(new Blob([bytes.slice()]), first.name); }