title: Upload files using Faraday
body: <p>I'm having issues attempting to upload a file to a web service using Faraday.</p>
  
  <p>My code:</p>
  
  <pre><code>conn = Faraday.new('http://myapi') do |f|
    f.request :multipart
  end
  
  payload = { :file =&gt; Faraday::UploadIO.new('...', 'image/jpeg') }
  
  conn.post('/', payload)
  </code></pre>
  
  <p>Nothing seems to happen after attempting the post. When I inspect the response <a href="https://gist.github.com/anonymous/5640095" rel="nofollow">this</a> is what I'm seeing:</p>
  
  <pre><code>#&lt;Faraday::Response:0x007fd9e5903870 @env={:method=&gt;:post, :body=&gt;#&lt;Faraday::CompositeReadIO:0x007fd9e5903a50 @parts=[#&lt;Parts::FilePart:0x007fd9e5903e38 @head="-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"file\"; filename=\"indymade-badge-horizontal.png\"\r\nContent-Length: 7821\r\nContent-Type: image/png\r\nContent-Transfer-Encoding: binary\r\n\r\n", @foot="\r\n", @length=8026, @io=#&lt;CompositeReadIO:0x007fd9e5903b68 @ios=[#&lt;StringIO:0x007fd9e5903bb8&gt;, #&lt;UploadIO:0x007fd9e514a3b8 @content_type="image/png", @original_filename="indymade-badge-horizontal.png", @local_path="/Users/anthonator/Downloads/indymade-badge-horizontal.png", @io=#&lt;File:/Users/anthonator/Downloads/indymade-badge-horizontal.png&gt;, @opts={}&gt;, #&lt;StringIO:0x007fd9e5903b90&gt;], @index=0&gt;&gt;, #&lt;Parts::EpiloguePart:0x007fd9e5903ac8 @part="-------------RubyMultipartPost--\r\n\r\n", @io=#&lt;StringIO:0x007fd9e5903a78&gt;&gt;], @ios=[#&lt;CompositeReadIO:0x007fd9e5903b68 @ios=[#&lt;StringIO:0x007fd9e5903bb8&gt;, #&lt;UploadIO:0x007fd9e514a3b8 @content_type="image/png", @original_filename="indymade-badge-horizontal.png", @local_path="/Users/anthonator/Downloads/indymade-badge-horizontal.png", @io=#&lt;File:/Users/anthonator/Downloads/indymade-badge-horizontal.png&gt;, @opts={}&gt;, #&lt;StringIO:0x007fd9e5903b90&gt;], @index=0&gt;, #&lt;StringIO:0x007fd9e5903a78&gt;], @index=0&gt;, :url=&gt;#&lt;URI::HTTPS:0x007fd9e5909d60 URL:https://myapi&gt;, :request_headers=&gt;{"User-Agent"=&gt;"Faraday v0.8.7", "Content-Type"=&gt;"multipart/form-data;boundary=-----------RubyMultipartPost", "Content-Length"=&gt;"8062"}, :parallel_manager=&gt;nil, :request=&gt;{:proxy=&gt;nil, :boundary=&gt;"-----------RubyMultipartPost"}, :ssl=&gt;{}, :response=&gt;#&lt;Faraday::Response:0x007fd9e5903870 ...&gt;}, @on_complete_callbacks=[]&gt;
  irb(main):065:0&gt; response.inspect
  =&gt; "#&lt;Faraday::Response:0x007fd9e5903870 @env={:method=&gt;:post, :body=&gt;#&lt;Faraday::CompositeReadIO:0x007fd9e5903a50 @parts=[#&lt;Parts::FilePart:0x007fd9e5903e38 @head=\"-------------RubyMultipartPost\\r\\nContent-Disposition: form-data; name=\\\"file\\\"; filename=\\\"indymade-badge-horizontal.png\\\"\\r\\nContent-Length: 7821\\r\\nContent-Type: image/png\\r\\nContent-Transfer-Encoding: binary\\r\\n\\r\\n\", @foot=\"\\r\\n\", @length=8026, @io=#&lt;CompositeReadIO:0x007fd9e5903b68 @ios=[#&lt;StringIO:0x007fd9e5903bb8&gt;, #&lt;UploadIO:0x007fd9e514a3b8 @content_type=\"image/png\", @original_filename=\"indymade-badge-horizontal.png\", @local_path=\"/Users/anthonator/Downloads/indymade-badge-horizontal.png\", @io=#&lt;File:/Users/anthonator/Downloads/indymade-badge-horizontal.png&gt;, @opts={}&gt;, #&lt;StringIO:0x007fd9e5903b90&gt;], @index=0&gt;&gt;, #&lt;Parts::EpiloguePart:0x007fd9e5903ac8 @part=\"-------------RubyMultipartPost--\\r\\n\\r\\n\", @io=#&lt;StringIO:0x007fd9e5903a78&gt;&gt;], @ios=[#&lt;CompositeReadIO:0x007fd9e5903b68 @ios=[#&lt;StringIO:0x007fd9e5903bb8&gt;, #&lt;UploadIO:0x007fd9e514a3b8 @content_type=\"image/png\", @original_filename=\"indymade-badge-horizontal.png\", @local_path=\"/Users/anthonator/Downloads/indymade-badge-horizontal.png\", @io=#&lt;File:/Users/anthonator/Downloads/indymade-badge-horizontal.png&gt;, @opts={}&gt;, #&lt;StringIO:0x007fd9e5903b90&gt;], @index=0&gt;, #&lt;StringIO:0x007fd9e5903a78&gt;], @index=0&gt;, :url=&gt;#&lt;URI::HTTPS:0x007fd9e5909d60 URL:https://myapi&gt;, :request_headers=&gt;{\"User-Agent\"=&gt;\"Faraday v0.8.7\", \"Content-Type\"=&gt;\"multipart/form-data;boundary=-----------RubyMultipartPost\", \"Content-Length\"=&gt;\"8062\"}, :parallel_manager=&gt;nil, :request=&gt;{:proxy=&gt;nil, :boundary=&gt;\"-----------RubyMultipartPost\"}, :ssl=&gt;{}, :response=&gt;#&lt;Faraday::Response:0x007fd9e5903870 ...&gt;}, @on_complete_callbacks=[]&gt;"
  </code></pre>
  
  <p>The body is being set to a CompositeReadIO object and it seems to never be sending out a request.</p>