@worksafevictoria/wcl7.5 1.1.0-beta.84 → 1.1.0-beta.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseFormElement } from '../base-form-element'
|
|
2
|
-
import { Buffer } from 'buffer'
|
|
3
2
|
|
|
4
3
|
export class FileFormElement extends BaseFormElement {
|
|
5
4
|
getType() {
|
|
@@ -10,11 +9,17 @@ export class FileFormElement extends BaseFormElement {
|
|
|
10
9
|
const promises = await Promise.all(
|
|
11
10
|
value.map((file) => {
|
|
12
11
|
const base64Data = file.url.split(',')[1]
|
|
13
|
-
const buffer = Buffer.from(base64Data, 'base64')
|
|
12
|
+
//const buffer = Buffer.from(base64Data, 'base64')
|
|
13
|
+
const binaryData = atob(base64Data)
|
|
14
|
+
const byteArray = new Uint8Array(binaryData.length)
|
|
15
|
+
for (let i = 0; i < binaryData.length; i++) {
|
|
16
|
+
byteArray[i] = binaryData.charCodeAt(i)
|
|
17
|
+
}
|
|
18
|
+
const blob = new Blob([byteArray], { type: 'text/plain' })
|
|
14
19
|
|
|
15
20
|
return axios.post(
|
|
16
21
|
`https://content-dev-v2.api.worksafe.vic.gov.au/webform_rest/${this.webformElement['#webform']}/upload/file`,
|
|
17
|
-
|
|
22
|
+
blob,
|
|
18
23
|
{
|
|
19
24
|
headers: {
|
|
20
25
|
'Content-Type': 'application/octet-stream',
|