Created
September 22, 2016 16:06
-
-
Save glenjamin/142b40775c0ec616e84deaa5bafd90f2 to your computer and use it in GitHub Desktop.
Revisions
-
glenjamin created this gist
Sep 22, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ /** * Get a promise for a user-selected File object */ export function chooseLocalFile(): Promise<File> { const input = document.createElement("input"); input.type = "file"; input.accept = "application/json"; return new Promise((resolve) => { input.addEventListener("change", () => { const file = input.files[0]; resolve(file); }); input.click(); }); }