diff options
| author | RblSb <msrblsb@gmail.com> | 2025-10-23 01:30:22 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2025-10-23 01:30:22 +0300 |
| commit | ee3eddc6b80565f6bb458a1fd8f3a83fdd37d554 (patch) | |
| tree | f8899cd76766e2eb7dd09969c5d91c5d11dd6c69 /src/client/Utils.hx | |
| parent | d4fb50df4f77cb8d039eaecdc8f6467c5fef4d22 (diff) | |
Fix large file upload
Diffstat (limited to 'src/client/Utils.hx')
| -rw-r--r-- | src/client/Utils.hx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/client/Utils.hx b/src/client/Utils.hx index 2234a1b..54025aa 100644 --- a/src/client/Utils.hx +++ b/src/client/Utils.hx @@ -6,6 +6,7 @@ import js.Browser.navigator; import js.Browser.window; import js.html.Blob; import js.html.Element; +import js.html.File; import js.html.FileReader; import js.html.URL; import js.html.audio.AudioContext; @@ -181,6 +182,26 @@ class Utils { input.click(); } + /** Don't extract data for bigger files. **/ + public static function browseJsFile( + onFileSelected:(file:File) -> Void + ):Void { + final input = document.createInputElement(); + input.style.visibility = "hidden"; + input.type = "file"; + input.id = "browse"; + input.onclick = e -> { + e.cancelBubble = true; + e.stopPropagation(); + } + input.onchange = e -> { + final file = input.files[0] ?? return; + onFileSelected(file); + } + document.body.appendChild(input); + input.click(); + } + public static function saveFile(name:String, mime:Mime, data:String):Void { final blob = new Blob([data], { type: mime |
