import { OneBlinkUploader } from '@oneblink/uploads'
const uploader = new OneBlinkUploader({
apiOrigin: 'https://auth-api.blinkm.io',
region: 'ap-southeast-2',
getBearerToken: () => getAccessToken(),
})
Upload an attachment for use with the AI builder.
const abortController = new AbortController()
const result = await uploader.uploadAiBuilderAttachment({
onProgress: (progress) => {
// ...
},
data: attachmentData,
formId: 1,
abortSignal: abortController.signal,
})
The attachment data and options
The upload result
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',
})
The asset upload data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
A standard MIME type describing the format of the contents
The file data to upload
The name of the file being uploaded
The identifier for the organisation that owns the asset
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,
})
The attachment upload data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
A standard MIME type describing the format of the contents
The file data to upload
The name of the file being uploaded
The identifier for the form that is being completed
Set to true to prevent the file from being downloaded publicly
Optionalusername?: stringA username to allow a single user to download the attachment file
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,
})
The email attachment data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
A standard MIME type describing the format of the contents
The file data to upload
The name of the file being uploaded
The upload result
Upload a draft submission.
const result = await uploader.uploadDraftSubmission({
submission: {
// ...
},
definition: {
// ...
},
formsAppId: 1,
formSubmissionDraftId: '',
createdAt: new Date().toISOString(),
title: '',
onProgress: (progress) => {
// ...
},
})
The submission upload data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
The form that is being submitted
Optionaldevice?: S3SubmissionDataDeviceThe device the form is being submitted
OptionalexternalId?: stringThe external identifier that represents the submission
OptionalformsAppId?: numberThe identifier for the forms app that is being submitted from
OptionaljobId?: stringThe identifier of the job that will be marked as submitted
OptionalpreviousFormSubmissionApprovalId?: stringThe identifier for the previous FormSubmissionApproval that lead to a clarification request
The submission data
OptionaltaskActionId?: stringThe identifier of the task action that was used to complete the task
OptionaltaskGroupInstanceId?: stringThe identifier of the task group instance that the completed task is associated with
OptionaltaskId?: stringThe identifier of the task that will be marked as completed
OptionaluserToken?: stringAn encrypted token that represents the user
The date and time (in ISO format) when the draft data was saved by a user.
The identifier of the draft that a new version should be created for.
OptionallastElementUpdated?: FormElementThe identifier for the last element that was used before saving draft
OptionalpreviousElapsedDurationSeconds?: numberThe previously elapsed duration in seconds before saving draft
OptionalsectionState?: { id: string; state: "COLLAPSED" | "EXPANDED" }[]The open/closed state of collapsible sections before saving draft
The title input by a user to identify the draft.
The upload result
Upload a PDF for conversion. PDF Conversions are always private.
const abortController = new AbortController()
const result = await uploader.uploadPDFConversion({
onProgress: (progress) => {
// ...
},
data: pdfData,
formId: 1,
abortSignal: abortController.signal,
})
The PDF data and options
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,
})
The prefill upload data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
The identifier for the form that the prefill data is associated with
The prefill data to upload
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,
})
The asset upload data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
A standard MIME type describing the format of the contents
The file data to upload
The name of the file being uploaded
The upload result
Upload a submission.
const result = await uploader.uploadSubmission({
submission: {
// ...
},
definition: {
// ...
},
formsAppId: 1,
onProgress: (progress) => {
// ...
},
})
The submission upload data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
The form that is being submitted
Optionaldevice?: S3SubmissionDataDeviceThe device the form is being submitted
OptionalexternalId?: stringThe external identifier that represents the submission
OptionalformsAppId?: numberThe identifier for the forms app that is being submitted from
OptionaljobId?: stringThe identifier of the job that will be marked as submitted
OptionalpreviousFormSubmissionApprovalId?: stringThe identifier for the previous FormSubmissionApproval that lead to a clarification request
The submission data
OptionaltaskActionId?: stringThe identifier of the task action that was used to complete the task
OptionaltaskGroupInstanceId?: stringThe identifier of the task group instance that the completed task is associated with
OptionaltaskId?: stringThe identifier of the task that will be marked as completed
OptionaluserToken?: stringAn encrypted token that represents the user
OptionalcompletionTimestamp?: stringThe date and time (in ISO format) the form was completed I.e. when the user clicked the submit button
OptionalformSubmissionDraftId?: stringThe identifier of the draft to mark as submitted.
Optionalrecaptchas?: { siteKey: string; token: string }[]The reCAPTCHA tokens to validate the submission
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,
})
The asset upload data and options
OptionalonProgress?: ProgressListenerAn optional progress listener for tracking the progress of the upload
A standard MIME type describing the format of the contents
The file data to upload
The name of the file being uploaded
The identifier for the volunteers app that owns the asset
The upload result
Used to create an instance of the OneBlinkUploader, exposing methods to upload submissions and other types of files