Entity files are files uploaded to a relevant entity. Possible files, for example, would be a pitch deck for an opportunity or a physical mail correspondence for a person.

Properties

Methods

Properties

pagedIterator: ((params: Omit<undefined | AllEntityFileRequest, keyof PagedRequest> & Omit<PagedRequest, "page_token">) => AsyncGenerator<Unwrapped<FN, PAYLOAD_KEY>>) = ...

Returns an async iterator that yields all entity files matching the given request Each yielded array contains up to the number specified in AllEntityFileRequest.page_size of entity files. Use this method if you want to process the entity files in a streaming fashion.

Please note: the yielded entity files array may be empty on the last page.

let page = 0
for await (const entries of affinity.entityFiles.pagedIterator({
person_id: 123,
page_size: 10
})) {
console.log(`Page ${++page} of entries:`, entries)
}

Methods

  • Downloads the entity file with the specified entity_file_id.

    Parameters

    • entity_file_id: number

    Returns Promise<Readable>

    import { promises as fsPromises } from 'node:fs';
    const fileResponseStream = affinity.entityFiles.download(123);
    await fsPromises.writeFile(filePath, fileResponseStream);
  • Uploads files attached to the entity with the given id.

    The file will display on the entity's profile, provided that the entity is not a person internal to the user's organization.

    Parameters

    Returns Promise<boolean>

    const entityFile = await affinity.entityFiles.upload({
    files: ['/path/to/example.pdf'],
    person_id: 123,
    });