Fork me on GitHub

Hey all. I have an endpoint that downloads a file. I'm trying to trigger that download from CLJS(reagent). I can see the request and the responese(inside the network tab) that shwos the file has been downloaded. but I would like to actually trigger a download that requests saving to disk. I'm unsure of where to find resources for this


Usually for these things, it's worth checking out how it's handled in JS and then do the same thing with interop. I've never done this either, but it seems that as of HTML5, you can set a download attribute on an a element, like this:


I.e., you set the URI to be the file content. The download attribute instructs the browser to save the URI as a file rather than navigating to it.


My recollection is that this is controlled by the content-disposition header


Thank you guys


I'll try this otu and report back

👍 5

I asked this on clojure channel but maybe this more appropriate place


daniel.spaniel [10:32 AM] Howdy, I am trying to send a pdf ( as ByteArrayOutputStream ) back to front end in the body of the http response. In our middle wear stack >> Transit << is barfing on that ( NullPointer ) so I am wondering if there is something I am missing. Do i have to make custom handler for transit or something? my response looks like this {:status 200 :body pdf-output-stream :headers {"Content-Type" content-type}} where pdf-output-stream is the byte array output stream


Hm, shouldn't your transit middleware skip byte stream payload based on content type?


errr .. aaa .. i guess not ? i am checking the transit code and it looks like they convert output stream to byte array then to string like (String. (.toByteArray out)


but i just guessing


the answer was to create ByteArrayInputStream from the (.toByteArray out) and use that in the body

Philipp Grigoryev16:02:48

hi guys, a newb here trying to follow modern-cljs tutorial. Ran into an issue with boot-cljs-test class clojure.lang.Var$Unbound cannot be cast to class clojure.lang.IAtom Can anybody give an advice where to dig? I've already submitted an issue on the boot-cljs-test repo. Thx in advance


I'm feeling a little overwhelmed here. I'm trying to use a nodejs npm library with clojurescript. What is the preferred method to do so these days, which provides a figwheel and repl style development? Is there a tuturial or lein template that I can start off with? Thanks!


#shadow-cljs seems what your looking for. Is send to work better then either using npm-deps or using clojurescript with webpack.


I'll check it out. How does it differ from Lumo?


Don't know Lumo much. Is't an alternative clojurescript compiler, with baked in code reloading and better support for npm.

👍 5