Load attachments

In the load attachments phase, the snap-in saves each attachment to the external system.

Triggering event

Airdrop initiates the load attachments phase by starting the snap-in with a message containing an event of type START_LOADING_ATTACHMENTS.

Implementation

This phase is defined in load-attachments.ts.

The loading process involves providing the create function to add attachments to the external system. The create function is responsible for making API calls to the external system to create the attachments, as well as handling errors and the external system’s rate limiting. The function should return the id and optionally modifiedDate of the record in the external system or indicates a rate-limiting back-off or logs errors if the attachment could not be created.

1processTask<LoaderState>({
2 task: async ({ adapter }) => {
3 const { reports, processed_files } = await adapter.loadAttachments({
4 create: createAttachment,
5 });
6
7 await adapter.emit(LoaderEventType.AttachmentLoadingDone, {
8 reports,
9 processed_files,
10 });
11 },
12 onTimeout: async ({ adapter }) => {
13 await adapter.emit(LoaderEventType.AttachmentLoadingProgress, {
14 reports: adapter.reports,
15 processed_files: adapter.processedFiles,
16 });
17 },
18});
Built with