diff --git a/package.json b/package.json index a68db61..9173e98 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "antd": "^3.13.2", "crypto-js": "^3.1.9-1", "file-saver": "^2.0.0", - "file-to-array-buffer": "^1.0.0", "jszip": "^3.1.5", "react": "^16.8.2", "react-app-rewired": "^2.1.0", @@ -37,4 +36,4 @@ "not op_mini all" ], "devDependencies": {} -} +} \ No newline at end of file diff --git a/src/worker/handleFiles.js b/src/worker/handleFiles.js index 09010b5..7c90056 100644 --- a/src/worker/handleFiles.js +++ b/src/worker/handleFiles.js @@ -1,10 +1,10 @@ import JSZip from "jszip"; import CryptoJS from "crypto-js"; -import fileToArrayBuffer from "file-to-array-buffer"; import { b64toBlob, base64ArrayBuffer, - asyncForEach + asyncForEach, + fileToArrayBuffer } from "./utils"; export const getSHA256 = async (value) => { diff --git a/src/worker/utils.js b/src/worker/utils.js index e008374..7e27371 100644 --- a/src/worker/utils.js +++ b/src/worker/utils.js @@ -24,6 +24,21 @@ export function b64toBlob(b64Data, contentType, sliceSize) { return blob; } +export function fileToArrayBuffer(file) { + return new Promise(function (resolve, reject) { + const reader = new FileReader() + + reader.onerror = function onerror(ev) { + reject(ev.target.error) + } + + reader.onload = function onload(ev) { + resolve(ev.target.result) + } + + reader.readAsArrayBuffer(file) + }) +} export function base64ArrayBuffer(arrayBuffer) { var base64 = "";