diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 15:54:12 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:01:12 +0100 |
commit | 8dc1e0ea0819ee6ec8f6407a58650bfedca3db31 (patch) | |
tree | abb55012bd3d96989bad2f301d052bc30bfdda93 | |
parent | b941c8c059012d6497553f564fe3cb5cd7b6f75c (diff) |
Added a transfert module in common elements
-rwxr-xr-x | lib/elements/transfert.ml | 14 |
1 files 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 |