-
Notifications
You must be signed in to change notification settings - Fork 2
/
j2x.clj
25 lines (23 loc) · 911 Bytes
/
j2x.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(ns milia.api.j2x
(:require [milia.api.http :refer [parse-http]]
[milia.utils.file :as file-utils]
[milia.utils.remote :refer [make-j2x-url]]))
(defn upload-xls-template
"Upload xls template to j2x"
[media-file]
(let [url (make-j2x-url "templates")
data-file (file-utils/uploaded->file media-file)
data-file-bytes (file-utils/to-byte-array data-file)]
(parse-http :post
url
:http-options {:body data-file-bytes}
:raw-response? true
:suppress-4xx-exceptions? true
:as-map? true)))
(defn download-xls-report-template
"Download xls report template from the j2x service"
[filename template-token]
(let [url (make-j2x-url "templates" template-token)]
(parse-http :get url
:http-options {:as :byte-array}
:as-map? true :filename filename)))