Web SDKv1.0.0

AttachmentsApi.data()

One attachment's bytes. Needs the extract feature.
methodReadingsince 1.0.0

Signature

data(index: number): Promise<Uint8Array>

Parameters

ParameterTypeDescription
indexnumberThe attachment's index, as list() reports it.

Returns

Promise<Uint8Array> The attachment's bytes.

Throws

  • INVALID_ARGUMENT — an index that 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 lacks extract.
  • 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);
}

More in AttachmentsApi