compojure-api
compojure-api copied to clipboard
File upload for clojure spec
The current file upload wiki: https://github.com/metosin/compojure-api/wiki/Swagger-aware-File-uploads only works with schema. How to do this with clojure spec? Thanks.
You can use any? can be used as a prediate.
oh, the language :O
Using any? won't have the coercion that makes it easy for me to access the file via something like upload/TempFileUpload?
(s/def :file/filename string?)
(s/def :file/content-type string?)
(s/def :file/size integer?)
(s/def :file/tempfile #(instance? java.io.File %))
(s/def ::file (st/spec {:spec (s/keys :req-un [:file/filename :file/content-type :file/size]
:opt-un [:file/tempfile])
:json-schema/type "file"}))
nice! ~s/:file\//::/g, this could be under compojure.api.specs?