Skip to content

Swagger aware File uploads

Daniel Petranek edited this page Mar 2, 2016 · 4 revisions

Mostly provided by Ring-Swagger. Restructuring :multipart-params pushes also multipart/form-data as the only available consumption.

;; versions before 0.23.0
(require '[compojure.api.upload :as upload])

;; versions 0.23.0+
(require '[ring.swagger.upload :as upload])

; file is a map with :filename, :content-type, :size and :tempfile as keys
(POST "/upload" []
  :multipart-params [file :- upload/TempFileUpload]
  :middleware [upload/wrap-multipart-params]
  (ok (dissoc file :tempfile)))