Skip to content

Commit

Permalink
Added guards for Multipart.add_file
Browse files Browse the repository at this point in the history
  • Loading branch information
secretworry committed Apr 22, 2017
1 parent 27b625e commit 3788e6a
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit 3788e6a

Please sign in to comment.