Sample project shows how to accept file upload with Pedestal
Start Server
$ lein run
$ curl localhost:8080
ok%
$ curl -X POST -H "content-type: multipart/form-data" localhost:8080/upload -F "image=@docs/clojure_logo.png"
[137 80 78 71 13 10 26 10 0 0 0 13 73 72 68 82 0 0 0 8 0 0 0 8 8 6 0 0 0 196 15 190 139 0 0 0 1 115 82 71 66 0 174 206 28 233 0 0 0 9 112 72 89 115 0 0 11 19 0 0 11 19 1 0 154 156 24 0 0 1 89 105 84 88 116 88 77 76 58 99 111 109 46 97 100 111 98 101 46 120 109 112 0 0 0 0 0 60 120 58 120 109 112 109 101 116 97 32 120 109 108 110 115 58 120 61 34 97 100 111 98 101 58 110 115 58 109 101 116 97 47 34 32 120 58 120 109 112 116 107 61 34 88 77 80 32 67 111 114 101 32 53 46 52 46 48 34 62 10 32 32 32 60 114 100 102 58 82 68 70 32 120 109 108 110 115 58 114 100 102 61 34 104 116 116 112 58 47 47 119 119 119 46 119 51 46 111 114 103 47 49 57 57 57 47 48 50 47 50 50 45 114 100 102 45 115 121 110 116 97 120 45 110 115 35 34 62 10 32 32 32 32 32 32 60 114 100 102 58 68 101 115 99 114 105 112 116 105 111 110 32 114 100 102 58 97 98 111 117 116 61 34 34 10 32 32 32 32 32 32 32 32 32 32 32 32 120 109 108 110 115 58 116 105 102 102 61 34 104 116 116 112 58 47 47 110 115 46 97 100 111 98 101 46 99 111 109 47 116 105 102 102 47 49 46 48 47 34 62 10 32 32 32 32 32 32 32 32 32 60 116 105 102 102 58 79 114 105 101 110 116 97 116 105 111 110 62 49 60 47 116 105 102 102 58 79 114 105 101 110 116 97 116 105 111 110 62 10 32 32 32 32 32 32 60 47 114 100 102 58 68 101 115 99 114 105 112 116 105 111 110 62 10 32 32 32 60 47 114 100 102 58 82 68 70 62 10 60 47 120 58 120 109 112 109 101 116 97 62 10 76 194 39 89 0 0 1 19 73 68 65 84 24 25 1 8 1 247 254 1 0 0 0 0 242 242 242 38 211 221 250 139 229 233 249 65 255 255 1 0 40 33 12 191 46 39 13 117 1 1 1 218 4 255 255 255 38 231 233 252 207 237 242 7 10 222 230 248 0 5 6 251 0 185 212 245 78 83 234 247 68 255 255 255 49 1 246 249 245 177 211 237 203 78 25 15 12 247 251 247 38 8 217 224 13 0 8 0 243 248 163 191 245 9 112 77 10 178 3 57 88 48 154 201 225 188 7 242 9 214 4 247 253 241 1 226 221 46 1 9 12 7 4 9 252 238 1 243 246 252 26 2 246 251 243 0 15 7 19 0 17 6 35 0 10 7 247 0 28 23 248 0 244 246 0 0 238 244 253 0 8 6 2 0 2 40 22 48 191 208 247 168 0 22 251 45 248 15 7 29 255 36 35 228 255 58 36 0 248 74 61 26 0 69 56 20 191 1 255 255 255 38 184 214 174 207 180 232 142 10 38 6 67 0 254 1 245 0 16 15 14 0 60 23 78 246 36 21 48 49 4 1 1 1 218 255 255 255 49 26 15 29 139 218 235 211 65 0 254 2 0 28 11 34 191 29 14 48 117 1 1 1 218 3 202 115 29 43 8 233 38 0 0 0 0 73 69 78 68 174 66 96 130]
;; sample of how a File form param look as part of a Request
;; (-> request :params }
{
...
:params {"image" {:filename "clojure_logo.png",
:content-type "application/octet-stream",
:tempfile #object[java.io.File 0x5a13723f "/var/folders/mc/b8d36rds5x3696gyq04gf6wjjd1mc/T/ring-multipart-6079485883736612817.tmp"],
:size 8186}}
}
Copyright © 2016
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.