Fork me on GitHub
#luminus
<
2016-02-23
>
eggsyntax00:02:14

Is anyone aware of an issue with clj-http and including file attachments in a POST? I realize this isn't a clj-http group, but I couldn't think of a better one...I'm trying to send an email w/ attachment through the Mailgun API, and the email goes through fine but the attachment has vanished.

audaxion01:02:50

can anyone help me with mount at all?

audaxion01:02:14

my db mount config only starts when i explicitly load the file in my REPL

mikeb02:02:57

@eggsyntax: I've done a bit of work with mailgun in the past. Perhaps you're missing the proper http post content type? See http://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data

eggsyntax03:02:55

@mikeb: I'm definitely specifying content type. I've tried quite a few variants, but I'm doing roughly:

(client/post (url ["messages"])
               {:to test-address
                :from from
                :subject "TEST 6"
                :text "So funny such banana, wow"
                :multipart [{:name "title" :content "My Awesome Picture"}
                            {:name "Content/type" :content "image/jpeg"}
                            {:name "file"
                             :content (FileBody.
                                       ( "resources/banana.jpg"))}]
                :basic-auth ["api" api-key]})

eggsyntax03:02:03

Or, hmm, maybe what that's saying isn't about content type of the attachment, but about the whole post? I'll have to look into that more.

eggsyntax03:02:41

I'm still very much learning about http protocols...

mikeb03:02:50

I was thinking of the whole post. Perhaps it detects that automatically because it's got parts.

eggsyntax03:02:32

Gotcha. I'm not sure. I'm looking at the examples in the clj-http docs (https://github.com/dakrone/clj-http#post) for guidance and trying to reconcile that with mailgun's expectations (per https://documentation.mailgun.com/user_manual.html#sending-via-api).

eggsyntax03:02:19

Are those content types specifically for MIME representations? That's also not quite clear to me, whether clj-http is producing a MIME representation or not.

eggsyntax03:02:10

I started digging into the clj-http source code a while ago, & will probably dig back in tomorrow morning, it seems promising. But I gotta run to bed now. Thanks for the help!

eggsyntax03:02:34

Didn't get nearly enough sleep last night, gotta try to make up for it tonight 😉

mikeb03:02:17

I'm trying a quick test, let me see if I can get something working.

eggsyntax03:02:24

Ah, cool, thanks!

mikeb04:02:20

@eggsyntax: yeah, that clj-http file upload api and mailgun are not playing well at all.

eggsyntax13:02:51

@mikeb: thanks! I’m glad to have independent confirmation. I sure had trouble getting it to work, but it was entirely possible that I was doing something silly.

jbaiter18:02:26

is there a way to run mount/start during figwheel startup?

curtis.summers18:02:48

@jbaiter Looking at the figwheel docs for component, it might be the other way around: mount/start would need to set up figwheel. See https://github.com/bhauman/lein-figwheel#scripting-with-component

curtis.summers19:02:32

@jbaiter you might also ask this in #C0H7M5HFE

jbaiter19:02:44

@curtis.summers: thanks, I hoped there was an easier way simple_smile "lein figwheel" is just so damn convenient

tolitius22:02:22

@jbaiter: I don't know figwheel well enough, but can you have (mount/start) in one your cljs files? or there is a reason you need it to start with figwheel?

yogthos22:02:32

it might make sense to stick that in `env/dev/cljs/<app>/dev.cljs

yogthos22:02:03

I’m assuming you mean the cljs mount

yogthos22:02:25

for the server side, I tend to use lein run to start up the server part in addition to running lein figwheel

yogthos22:02:48

figwheel isn’t aware of the init function, so it only uses the handler without running code at startup

yogthos22:02:21

might be worth opening an issue with a feature request to have figwheel support the :init and :destroy keys in its config