From 8dc1e0ea0819ee6ec8f6407a58650bfedca3db31 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 7 Feb 2022 15:54:12 +0100 Subject: Added a transfert module in common elements --- lib/elements/transfert.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/elements/transfert.ml b/lib/elements/transfert.ml index ddeecd0..f324509 100755 --- a/lib/elements/transfert.ml +++ b/lib/elements/transfert.ml @@ -1,6 +1,6 @@ -open Js_of_ocaml open Brr +(** Send a file to the user. *) let send : mime_type:Jstr.t -> filename:Jstr.t -> Jstr.t -> unit = fun ~mime_type ~filename content -> @@ -8,11 +8,13 @@ let send let base64data = Jv.apply btoa [| Jv.of_jstr content |] in - let mime = (Jv.Id.(of_jv @@ to_jv mime_type)) - and base64 = (Jv.Id.(of_jv @@ to_jv base64data)) - in - - let data = (Js.string "data:")##concat_3 mime (Js.string ";base64,") base64 in + let data = Jv.to_jstr @@ Jv.call + (Jv.of_string "data:") + "concat" + [| Jv.of_jstr mime_type + ; Jv.of_jstr (Jstr.v ";base64,") + ; base64data + |] in (* Create the link to download the the element, and simulate a click on it *) let a = El.a -- cgit v1.2.3