Skip to content

Commit

Permalink
Merge pull request #14 from oneblink/ON-39641
Browse files Browse the repository at this point in the history
ON-39641 # Added prefill data function
  • Loading branch information
Zaxist authored Apr 18, 2024
2 parents fb826f4 + b7c3b90 commit 4a42bf7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/OneBlinkUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,48 @@ export default class OneBlinkUploader {
isPublic: true,
})
}

/**
* Upload form prefill data.
*
* #### Example
*
* ```ts
* const abortController = new AbortController()
* const result = await uploader.uploadPrefillData({
* onProgress: (progress) => {
* // ...
* },
* data: {
* field1: 'abc',
* field2: 123,
* },
* formId: 12,
* abortSignal: abortController.signal,
* })
* ```
*
* @param data The prefill upload data and options
* @returns The upload result
*/
async uploadPrefillData({
formId,
prefillData,
onProgress,
abortSignal,
}: UploadOptions & {
/** The identifier for the form that the prefill data is associated with */
formId: number
/** The prefill data to upload */
prefillData: SubmissionTypes.NewS3SubmissionData['submission']
}) {
return await uploadToS3({
...this,
contentType: 'application/json',
body: JSON.stringify(prefillData),
key: `forms/${formId}/pre-fill`,
abortSignal,
onProgress,
})
}
}

0 comments on commit 4a42bf7

Please sign in to comment.