I need to allow the user to save content generated by Clojurescript to their local drive.
I do it using this code -
(defn- save-file
[filename content]
(let [lnk (get-element-by-id "file-export-link")
blob (js/Blob. (js/Array. content) {:type "text/plain"})]
(set! (.-href lnk) (.createObjectURL js/URL blob))
(set! (.-download lnk) filename)
(.click lnk)))
When the function runs it does a pseudo download to the named file. This works with ":optimizations :none".
When I try the same thing with ":optimizations :advanced", instead of doing a download and prompting to open or save a file, it moves the browser to a URL like: "blob:null/d9bbcdab-7c87-....etc"
I have tried Chas Emericks's url package
https://github.com/cemerick/url to create the URL but it still doesn't work.
Something is being munged by the optimization, but I am not sure what.
Does anyone have any ideas how to go about fixing this?