Skip to content

Instantly share code, notes, and snippets.

@Kungi
Last active November 20, 2015 09:53
Show Gist options
  • Save Kungi/3bbba631378de17cf08d to your computer and use it in GitHub Desktop.
Save Kungi/3bbba631378de17cf08d to your computer and use it in GitHub Desktop.
--ABC
Content-Disposition: form-data; name="file"; filename="a.txt"
Content-Type: text/plain
A
--ABC
Content-Disposition: form-data; name="description"
test_description
--ABC
Content-Disposition: form-data; name="name"
test_name
--ABC--
curl -X POST -H "Content-type: multipart/form-data; boundary=--ABC" --data-binary @a.txt http://localhost:3000/
(ns multipart-upload.handler
(:require [clojure.pprint :refer [pprint]] [compojure.core :refer :all]
[compojure.route :as route]
[ring.middleware.defaults :refer [wrap-defaults api-defaults]]))
(defroutes app-routes
(GET "/" [] "Hello World")
(POST "/" [] "Hello World")
(route/not-found "Not Found"))
(defn log-request [handler]
(fn [req]
(pprint req)
(handler req)))
(def app
(wrap-defaults (log-request app-routes) (-> api-defaults
(assoc-in [:params :multipart] true)
(assoc-in [:params :nested] true))))
{:ssl-client-cert nil,
:remote-addr "0:0:0:0:0:0:0:1",
:params {},
:headers
{"host" "localhost:3000",
"accept" "*/*",
"content-length" "241",
"content-type" "multipart/form-data; boundary=--ABC",
"user-agent" "curl/7.37.1"},
:server-port 3000,
:content-length 241,
:form-params {},
:query-params {},
:content-type "multipart/form-data; boundary=--ABC",
:character-encoding nil,
:uri "/",
:server-name "localhost",
:query-string nil,
:body
#object[org.eclipse.jetty.server.HttpInput 0x5f435901 "org.eclipse.jetty.server.HttpInput@5f435901"],
:multipart-params {},
:scheme :http,
:request-method :post}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment