Fork me on GitHub
#yada
<
2017-03-13
>
baris09:03:49

Hey all, I'm trying to upload an image as multipart/form-data. Following the manual (https://juxt.pro/yada/manual/index.html#capturing-large-request-bodies) I'd like to coerce the the image as java.io.File in the :parameters map. I get the the following error when trying to coerce the file param as java.io.File: manifold.deferred.ErrorDeferred cannot be cast to clojure.lang.Associative

baris09:03:57

I'm using the following libs:

[yada "1.2.1"]
[prismatic/schema "1.1.3"]
[yada "1.2.1" :exclusions [aleph manifold ring-swagger prismatic/schema]]
[aleph "0.4.2-alpha8"]
[manifold "0.1.6-alpha1"]

baris09:03:05

and the this yada/resource code to handle the file upload:

(yada/resource
	{:consumes "multipart/form-data"
	 :produces "application/json"
	 :methods {:post {:parameters {:form {:file java.io.File}}
					  :response (fn [ctx]
									(let [params (get-in ctx [:parameters :form])
										  file (:file params)]
										(println "store file ...")
										{:upload true}))}}})

baris09:03:12

What I'm doing wrong? Is there any example for file uploads or handle multipart data?

malcolmsparks09:03:47

The phonebook example uses multipart/formdata to update a user

baris09:03:35

Thx @malcolmsparks I've looked at this example already

baris09:03:03

unfortunately anything else then String in the :parameters map (like Long or java.io.File) cause the error manifold.deferred.ErrorDeferred cannot be cast to clojure.lang.Associative any idea why?

dominicm10:03:39

As an aside, Aleph 0.4.3 stable is now out!

baris11:03:27

upgraded aleph and manifold to the latest versions.....still the same issue

fabrao18:03:18

hello all, how can I use yada with https?

malcolmsparks18:03:52

Yes. Just configure aleph options @fabrao

fabrao19:03:41

ssl-context ?