From ee3eddc6b80565f6bb458a1fd8f3a83fdd37d554 Mon Sep 17 00:00:00 2001 From: RblSb Date: Thu, 23 Oct 2025 01:30:22 +0300 Subject: Fix large file upload --- src/client/Utils.hx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/client/Utils.hx') 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 -- cgit v1.2.3