@oneblink/storage
    Preparing search index...

    Class OneBlinkUploader

    Used to create an instance of the OneBlinkUploader, exposing methods to upload submissions and other types of files

    Index

    Constructors

    Properties

    apiOrigin: string
    getBearerToken: () => Promise<string | undefined>
    region: string

    Methods

    • Upload an asset file. Asset files are always public.

      const abortController = new AbortController()
      const result = await uploader.uploadAsset({
      onProgress: (progress) => {
      // ...
      },
      data: new Blob(['a string of data'], {
      type: 'text/plain',
      }),
      fileName: 'file.txt',
      contentType: 'text/plain',
      abortSignal: abortController.signal,
      organisationId: 'abc123',
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            contentType: string;
            data: AttachmentUploadData;
            fileName: string;
        } & { organisationId: string }

        The asset upload data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • contentType: string

          A standard MIME type describing the format of the contents

        • data: AttachmentUploadData

          The file data to upload

        • fileName: string

          The name of the file being uploaded

        • organisationId: string

          The identifier for the organisation that owns the asset

      Returns Promise<OneBlinkResponse<{ url: string }>>

      The upload result

    • Upload an form submission attachment.

      const abortController = new AbortController()
      const result = await uploader.uploadAttachment({
      formId: 1,
      data: new Blob(['a string of data'], {
      type: 'text/plain',
      }),
      fileName: 'file.txt',
      contentType: 'text/plain',
      isPrivate: true,
      abortSignal: abortController.signal,
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            contentType: string;
            data: AttachmentUploadData;
            fileName: string;
            formId: number;
            isPrivate: boolean;
            username?: string;
        }

        The attachment upload data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • contentType: string

          A standard MIME type describing the format of the contents

        • data: AttachmentUploadData

          The file data to upload

        • fileName: string

          The name of the file being uploaded

        • formId: number

          The identifier for the form that is being completed

        • isPrivate: boolean

          Set to true to prevent the file from being downloaded publicly

        • Optionalusername?: string

          A username to allow a single user to download the attachment file

      Returns Promise<
          OneBlinkResponse<
              { attachmentDataId: string; uploadedAt: string; url: string },
          >,
      >

      The upload result

    • Upload an email attachment. Email attachments are always private.

      Note: This function requires a JWT created from a Developer Key with the `Upload Attachments' permission set to 'On'. The OneBlink NodeJS SDK handles this for you with the uploadEmailAttachment function, and as such it is recommended you use that instead for uploading email attachments.

      const abortController = new AbortController()
      const result = await uploader.uploadEmailAttachment({
      onProgress: (progress) => {
      // ...
      },
      data: new Blob(['a string of data'], {
      type: 'text/plain',
      }),
      fileName: 'file.txt',
      contentType: 'text/plain',
      abortSignal: abortController.signal,
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            contentType: string;
            data: AttachmentUploadData;
            fileName: string;
        }

        The email attachment data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • contentType: string

          A standard MIME type describing the format of the contents

        • data: AttachmentUploadData

          The file data to upload

        • fileName: string

          The name of the file being uploaded

      Returns Promise<{ s3: S3Configuration }>

      The upload result

    • Upload a draft submission.

      const result = await uploader.uploadDraftSubmission({
      submission: {
      // ...
      },
      definition: {
      // ...
      },
      formsAppId: 1,
      formSubmissionDraftId: '',
      createdAt: new Date().toISOString(),
      title: '',
      onProgress: (progress) => {
      // ...
      },
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            definition: Form;
            device?: S3SubmissionDataDevice;
            externalId?: string;
            formsAppId?: number;
            jobId?: string;
            previousFormSubmissionApprovalId?: string;
            submission: { [name: string]: unknown };
            taskActionId?: string;
            taskGroupInstanceId?: string;
            taskId?: string;
            userToken?: string;
        } & {
            createdAt: string;
            formSubmissionDraftId: string;
            lastElementUpdated?: FormElement;
            previousElapsedDurationSeconds?: number;
            sectionState?: { id: string; state: "COLLAPSED"
            | "EXPANDED" }[];
            title: string;
        }

        The submission upload data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • definition: Form

          The form that is being submitted

        • Optionaldevice?: S3SubmissionDataDevice

          The device the form is being submitted

        • OptionalexternalId?: string

          The external identifier that represents the submission

        • OptionalformsAppId?: number

          The identifier for the forms app that is being submitted from

        • OptionaljobId?: string

          The identifier of the job that will be marked as submitted

        • OptionalpreviousFormSubmissionApprovalId?: string

          The identifier for the previous FormSubmissionApproval that lead to a clarification request

        • submission: { [name: string]: unknown }

          The submission data

        • OptionaltaskActionId?: string

          The identifier of the task action that was used to complete the task

        • OptionaltaskGroupInstanceId?: string

          The identifier of the task group instance that the completed task is associated with

        • OptionaltaskId?: string

          The identifier of the task that will be marked as completed

        • OptionaluserToken?: string

          An encrypted token that represents the user

        • createdAt: string

          The date and time (in ISO format) when the draft data was saved by a user.

        • formSubmissionDraftId: string

          The identifier of the draft that a new version should be created for.

        • OptionallastElementUpdated?: FormElement

          The identifier for the last element that was used before saving draft

        • OptionalpreviousElapsedDurationSeconds?: number

          The previously elapsed duration in seconds before saving draft

        • OptionalsectionState?: { id: string; state: "COLLAPSED" | "EXPANDED" }[]

          The open/closed state of collapsible sections before saving draft

        • title: string

          The title input by a user to identify the draft.

      Returns Promise<OneBlinkResponse<FormSubmissionDraftVersion>>

      The upload result

    • Upload form prefill data.

      Note: This function requires a JWT created from a Developer Key with the `Upload Form Prefill Data' permission set to 'On'. The OneBlink NodeJS SDK handles this for you with the generateFormUrl function, and as such it is recommended you use that instead for uploading prefill data.

      const abortController = new AbortController()
      const result = await uploader.uploadPrefillData({
      onProgress: (progress) => {
      // ...
      },
      data: {
      field1: 'abc',
      field2: 123,
      },
      formId: 12,
      abortSignal: abortController.signal,
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            formId: number;
            prefillData: { [name: string]: unknown };
        }

        The prefill upload data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • formId: number

          The identifier for the form that the prefill data is associated with

        • prefillData: { [name: string]: unknown }

          The prefill data to upload

      Returns Promise<OneBlinkResponse<{ preFillFormDataId: string }>>

      The upload result

    • Upload an asset file for a product service such as Product Notifications. Asset files are always public.

      const abortController = new AbortController()
      const result = await uploader.uploadAttachment({
      onProgress: (progress) => {
      // ...
      },
      data: new Blob(['a string of data'], {
      type: 'text/plain',
      }),
      fileName: 'file.txt',
      contentType: 'text/plain',
      abortSignal: abortController.signal,
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            contentType: string;
            data: AttachmentUploadData;
            fileName: string;
        }

        The asset upload data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • contentType: string

          A standard MIME type describing the format of the contents

        • data: AttachmentUploadData

          The file data to upload

        • fileName: string

          The name of the file being uploaded

      Returns Promise<OneBlinkResponse<{ url: string }>>

      The upload result

    • Upload a submission.

      const result = await uploader.uploadSubmission({
      submission: {
      // ...
      },
      definition: {
      // ...
      },
      formsAppId: 1,
      onProgress: (progress) => {
      // ...
      },
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            definition: Form;
            device?: S3SubmissionDataDevice;
            externalId?: string;
            formsAppId?: number;
            jobId?: string;
            previousFormSubmissionApprovalId?: string;
            submission: { [name: string]: unknown };
            taskActionId?: string;
            taskGroupInstanceId?: string;
            taskId?: string;
            userToken?: string;
        } & {
            completionTimestamp?: string;
            formSubmissionDraftId?: string;
            recaptchas?: { siteKey: string; token: string }[];
        }

        The submission upload data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • definition: Form

          The form that is being submitted

        • Optionaldevice?: S3SubmissionDataDevice

          The device the form is being submitted

        • OptionalexternalId?: string

          The external identifier that represents the submission

        • OptionalformsAppId?: number

          The identifier for the forms app that is being submitted from

        • OptionaljobId?: string

          The identifier of the job that will be marked as submitted

        • OptionalpreviousFormSubmissionApprovalId?: string

          The identifier for the previous FormSubmissionApproval that lead to a clarification request

        • submission: { [name: string]: unknown }

          The submission data

        • OptionaltaskActionId?: string

          The identifier of the task action that was used to complete the task

        • OptionaltaskGroupInstanceId?: string

          The identifier of the task group instance that the completed task is associated with

        • OptionaltaskId?: string

          The identifier of the task that will be marked as completed

        • OptionaluserToken?: string

          An encrypted token that represents the user

        • OptionalcompletionTimestamp?: string

          The date and time (in ISO format) the form was completed I.e. when the user clicked the submit button

        • OptionalformSubmissionDraftId?: string

          The identifier of the draft to mark as submitted.

        • Optionalrecaptchas?: { siteKey: string; token: string }[]

          The reCAPTCHA tokens to validate the submission

      Returns Promise<
          OneBlinkResponse<
              {
                  attachmentsAccessToken?: string;
                  pdfAccessToken?: string;
                  preventPayment: boolean;
                  submissionId: string;
                  submissionTimestamp: string;
              },
          >,
      >

      The upload result

    • Upload a volunteer asset file. Asset files are always public.

      const abortController = new AbortController()
      const result = await uploader.uploadVolunteersAsset({
      onProgress: (progress) => {
      // ...
      },
      data: new Blob(['a string of data'], {
      type: 'text/plain',
      }),
      fileName: 'file.txt',
      contentType: 'text/plain',
      abortSignal: abortController.signal,
      formsAppId: 1,
      })

      Parameters

      • data: DownloadOptions & { onProgress?: ProgressListener } & {
            contentType: string;
            data: AttachmentUploadData;
            fileName: string;
        } & { formsAppId: number }

        The asset upload data and options

        • OptionalonProgress?: ProgressListener

          An optional progress listener for tracking the progress of the upload

        • contentType: string

          A standard MIME type describing the format of the contents

        • data: AttachmentUploadData

          The file data to upload

        • fileName: string

          The name of the file being uploaded

        • formsAppId: number

          The identifier for the volunteers app that owns the asset

      Returns Promise<OneBlinkResponse<{ url: string }>>

      The upload result