Streaming a file using hackney
<p>I'm trying to stream a multipart form using hackney.</p>

<p>This is my current code:</p>

<pre><code>method = :post
path = "https://httpbin.org/post"
req_headers = [
  {"Content-Type", "multipart/form-data"}
]

{:ok, pid} = :hackney.request(method, path, req_headers, :stream, [])

:hackney.send_multipart_body(pid, {:file, "/Users/gmile/.vimrc"})

{:ok, _status, _headers, pid} = :hackney.start_response(pid)

{:ok, body} = :hackney.body(pid)
</code></pre>

<p>On line with <code>:hackney.send_multipart_body/2</code>, I see get exception:</p>

<pre><code>** (ArgumentError) argument error
    :erlang.byte_size(nil)
    (hackney) src/hackney_multipart.erl:134: :hackney_multipart.mp_header/2
    (hackney) src/hackney_multipart.erl:239: :hackney_multipart.mp_file_header/2
    (hackney) src/hackney_request.erl:222: :hackney_request.stream_multipart/2
    (hackney) src/hackney.erl:432: anonymous fn/2 in :hackney.send_multipart_body/2
    read_and_stream.exs:13: (file)
</code></pre>

<p>Question: <strong>what am I doing wrong?</strong></p>

<p>There's clearly a bug in my code, but since there's little documentation about <code>:hackney.send_multipart_body/2</code> I can't wrap my head around this.</p>

<hr>

<p>I started debugging. </p>

<p>Here's the execution path from the stacktrace, in the call order:</p>

<ol>
<li><a href="https://github.com/benoitc/hackney/blob/master/src/hackney.erl#L432" rel="nofollow noreferrer">https://github.com/benoitc/hackney/blob/master/src/hackney.erl#L432</a></li>
<li><a href="https://github.com/benoitc/hackney/blob/master/src/hackney_request.erl#L222" rel="nofollow noreferrer">https://github.com/benoitc/hackney/blob/master/src/hackney_request.erl#L222</a></li>
<li><a href="https://github.com/benoitc/hackney/blob/master/src/hackney_multipart.erl#L239" rel="nofollow noreferrer">https://github.com/benoitc/hackney/blob/master/src/hackney_multipart.erl#L239</a></li>
<li><a href="https://github.com/benoitc/hackney/blob/master/src/hackney_multipart.erl#L134" rel="nofollow noreferrer">https://github.com/benoitc/hackney/blob/master/src/hackney_multipart.erl#L134</a></li>
</ol>

<p>If I understand correctly, there should a <code>Boundary</code> variable set in the HTTP client process. However I can't seem to understand where it is being set.</p>