-
Notifications
You must be signed in to change notification settings - Fork 2
/
metadata.cljc
30 lines (28 loc) · 1.21 KB
/
metadata.cljc
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
26
27
28
29
30
(ns milia.utils.metadata
(:require [milia.api.http :refer [parse-http]]
#?(:clj [milia.utils.file :refer [uploaded->file]])
[milia.utils.remote :refer [make-url]]))
#?(:clj
(defn upload-metadata-file
"Upload `file` to metadata with name `id-name` for content `id`."
[id-name id file]
(let [url (make-url "metadata.json")
data-file (uploaded->file file)
muiltipart [{:name "data_value"
:content (:filename file)}
{:name "data_type"
:content "supporting_doc"}
{:name id-name
:content id}
{:name "data_file"
:content data-file}]]
(parse-http :post url
:http-options {:multipart muiltipart}
:suppress-4xx-exceptions? true))))
(defn metadata-files
"Fetch `metadata` with query key `id-key` and value `id`."
[id-key id no-cache? & {:keys [extra-params]}]
(parse-http :get (make-url "metadata.json")
:no-cache? no-cache?
:http-options {:query-params (conj {id-key id} extra-params)
:content-type :json}))