This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-24
Channels
- # announcements (2)
- # beginners (22)
- # cider (10)
- # clojure (47)
- # clojure-italy (2)
- # clojure-spec (2)
- # clojure-uk (1)
- # clojurebridge (5)
- # clojurescript (19)
- # cursive (1)
- # data-science (7)
- # datomic (2)
- # duct (18)
- # emacs (6)
- # figwheel-main (2)
- # java (2)
- # luminus (1)
- # nrepl (20)
- # off-topic (69)
- # om (3)
- # pathom (45)
- # quil (2)
- # re-frame (16)
- # reagent (1)
- # reitit (6)
- # ring (2)
- # shadow-cljs (33)
- # tools-deps (9)
- # vim (6)
- # yada (1)
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:
https://ourcodeworld.com/articles/read/189/how-to-create-a-file-and-generate-a-download-with-javascript-in-the-browser-without-a-server
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 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
May help too https://stackoverflow.com/questions/20508788/do-i-need-content-type-application-octet-stream-for-file-download
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 ..um .. 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
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?