Created
January 4, 2017 02:45
-
-
Save zhongwencool/9e0b895df041a7b721e08ceb98343d4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SendMultipartClient do | |
use Maxwell.Builder, ~w(post)a | |
middleware Maxwell.Middleware.BaseUrl, "http://httpbin.org" | |
middleware Maxwell.Middleware.Opts, [connect_timeout: 10000, recv_timeout: 20000] | |
middleware Maxwell.Middleware.DecodeJson | |
adapter Maxwell.Adapter.Hackney | |
@doc """ | |
Post multipart form | |
###Example | |
SendMultipartClient.post_multipart_form({:multipart, [{:file, "./mix.exs"}]}) | |
""" | |
def post_multipart_form(multipart) do | |
new | |
|> put_path("/post") | |
|> put_req_body(multipart) | |
|> post! | |
|> get_resp_body(["files", "file"]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment