diff options
author | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-07-01 16:56:14 +0530 |
---|---|---|
committer | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-07-01 16:56:14 +0530 |
commit | 0caf34bf91e51b7c1459b8b069daf3ec69ead855 (patch) | |
tree | cf0dd0b095687cfb70de76e5266f9facad0fd831 /src/Utils.ts | |
parent | 467afe6346bf3188461721fa78eed0f9ac214da7 (diff) | |
parent | a3ce7e180110df7e5908b93418b2dbff80aa89b5 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into acls_uv
Diffstat (limited to 'src/Utils.ts')
-rw-r--r-- | src/Utils.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index dba802f98..a01a94134 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -7,6 +7,22 @@ import { ColorState } from 'react-color'; export namespace Utils { export let DRAG_THRESHOLD = 4; + export function readUploadedFileAsText(inputFile: File) { + const temporaryFileReader = new FileReader(); + + return new Promise((resolve, reject) => { + temporaryFileReader.onerror = () => { + temporaryFileReader.abort(); + reject(new DOMException("Problem parsing input file.")); + }; + + temporaryFileReader.onload = () => { + resolve(temporaryFileReader.result); + }; + temporaryFileReader.readAsText(inputFile); + }); + } + export function GenerateGuid(): string { return v4(); } |