aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/elements/transfert.ml14
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