This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-26
Channels
- # announcements (7)
- # babashka (42)
- # beginners (349)
- # chlorine-clover (9)
- # cider (16)
- # circleci (2)
- # clj-kondo (6)
- # cljs-dev (61)
- # cljsrn (15)
- # clojure (95)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-spec (4)
- # clojure-uk (24)
- # clojurescript (21)
- # conjure (2)
- # core-async (8)
- # cursive (12)
- # datascript (2)
- # emacs (4)
- # exercism (1)
- # figwheel-main (86)
- # fulcro (27)
- # graalvm (4)
- # helix (36)
- # hoplon (3)
- # interop (44)
- # kaocha (6)
- # lein-figwheel (4)
- # malli (7)
- # meander (9)
- # off-topic (95)
- # pathom (33)
- # pedestal (13)
- # re-frame (20)
- # reitit (3)
- # shadow-cljs (102)
- # tools-deps (14)
- # xtdb (16)
https://github.com/trending/developers/clojure?since=monthly 🚀

Q: is there an example of how to use GZIPOutputStream in bb? I get a ClassCastException when I try to create one
I’m uploading static assets to s3. I want to gzip them so that they are served to browsers fast
I could use shell zip but I’m not sure it will be the same on osx vs linux (in CI)
cool! that class was included to support clj-http-lite, but good to know it's also being used in other ways
since you are here: I’m stuck on the final step. I have gzipped into a byte array but can’t work out how to write bytes out to a file
I mean, I can do this:
bb '(.write (java.util.zip.GZIPOutputStream. (io/output-stream "/tmp/foo.zip")) (.getBytes "dude"))'
but then what?(let [out-dir "public/editor-js"
in-file-name (str out-dir "/" (base-file-name out-dir))
out-file-name (str in-file-name ".gz")]
(with-open [out-stream (io/output-stream out-file-name)
gzip (GZIPOutputStream. out-stream)]
(io/copy (io/file in-file-name) gzip)
(.finish gzip))
[out-file-name (.length (io/file out-file-name))])
final step is to upload to aws. for that I use the gist from Jeroen https://gist.github.com/jeroenvandijk/e4fca617cf3eea82d58bc87e37e35465#file-spire-clj-L31-L50
all the file name stuff is just to find the output file from shadow-cljs advanced compile
$ bb '(with-open [os (java.util.zip.GZIPOutputStream. (io/output-stream "/tmp/foo.zip"))] (.write os (.getBytes "dude")) (.finish os))'
$ bb '(slurp (java.util.zip.GZIPInputStream. (io/input-stream "/tmp/foo.zip")))'
"dude"