This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-19
Channels
- # admin-announcements (1)
- # adventofcode (14)
- # announcements (2)
- # asami (7)
- # babashka (9)
- # beginners (41)
- # calva (43)
- # cider (31)
- # clerk (2)
- # clojure (34)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (166)
- # clojure-uk (7)
- # clojurescript (4)
- # datomic (1)
- # fulcro (10)
- # garden (1)
- # hoplon (2)
- # humbleui (4)
- # hyperfiddle (12)
- # jobs-discuss (6)
- # quil (6)
- # ring (6)
- # shadow-cljs (55)
- # squint (8)
- # xtdb (26)
How do I return a CSV response? I want the user to be able to curl and endpoint and they should up with a csv file.
create an io/writer, write into that, then feed it into the http://ring.util.io like this:
❤️ 1
(-> (your-writer-function)
(rio/piped-input-stream)
(response/response)
(response/content-type "text/csv; charset=UTF-8")
(response/header "Content-Disposition" "attachment; filename=foobar.csv"))))
❤️ 1
I'm testing this out. How do I create the io/writer
?
I have this now:
(defn write-csv
"Takes a file (path, name and extension) and
csv-data (vector of vectors with all values) and
writes csv file."
[file csv-data]
(with-open [writer (io/writer file)]
(csv/write-csv writer csv-data)))
So I have tho io/writer
, but it's writing to a file. And it's being written to by csv/write-csv
. I'm uncertain about what goes where.