Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine multipart #61

Merged
merged 5 commits into from
Apr 24, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added guards for Multipart.add_file
  • Loading branch information
secretworry committed Apr 22, 2017
commit 3788e6ac7c1c2561d260b1167a646acecbdd5b03
8 changes: 5 additions & 3 deletions lib/maxwell/multipart.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ defmodule Maxwell.Multipart do
def new(), do: {:multipart, []}

@spec add_file(t, Path.t) :: t
def add_file(multipart, path) do
def add_file(multipart, path) when is_binary(path) do
append_part(multipart, {:file, path})
end

@spec add_file(t, Path.t, headers_t) :: t
def add_file(multipart, path, extra_headers) do
def add_file(multipart, path, extra_headers)
when is_binary(path) and is_list(extra_headers) do
append_part(multipart, {:file, path, extra_headers})
end

@spec add_file(t, Path.t, disposition_t, headers_t) :: t
def add_file(multipart, path, disposition, extra_headers) do
def add_file(multipart, path, disposition, extra_headers)
when is_binary(path) and is_tuple(disposition) and is_list(extra_headers) do
append_part(multipart, {:file, path, disposition, extra_headers})
end

Expand Down