title: Is it possible to upload a file with cURL from a pipe?
body: <p>I mean POSTing a standard file upload form. Usual command line contains this switch in this case:</p>
  
  <pre><code>-F "Filedata=@filename.zip"
  </code></pre>
  
  <p>However when I try to feed a named pipe made by linux command "mkfifo", eg. "mkfifo filename.zip", I always get an error message on the producer side:</p>
  
  <pre><code>curl: (23) Failed writing body (1856 != 16384)
  </code></pre>
  
  <p>And also some error message appears at consumer side of the fifo. I fed my fifo with another curl command on producer side, eg.:</p>
  
  <pre><code> curl http://example.com/archive.zip &gt; filename.zip
  </code></pre>
  
  <p>And on consumer side:</p>
  
  <pre><code>curl http://example.com/fileupload.php -F "file=@filename.zip"
  </code></pre>
  
  <p>When I pass a Content-Length HTTP header at the consumer side of my fifo, I don't get error message at the producer side, but error message still appears at the consumer (uploading) side, unsuccessful upload.</p>
  
  <pre><code> curl http://example.com/fileupload.php -F "file=@filename.zip" -H "Content-Length: 393594678"
  </code></pre>
  
  <p>I also tried feeding cURL file upload a non-named pipe, causing cURL to read data from stdin (marked as @-), like:</p>
  
  <pre><code>   curl -# http://example.com/archive.zip | curl -# http://example.com/fileupload.php -F "file=@-"
  </code></pre>
  
  <p>In this case upload is successful, however the downloading and uploading progress are not in sync, I can see too separate hashmark progress indicators, one for the download and one for the upload, rather consecutively and not operating at the same time. On the top of that remote file is always named as "-", but this is not an issue for me, can be renamed later.</p>
  
  <p>Further notice: I tried the aboves from a Ruby command line IRB / Pry session, and I have noticed that when I used Ruby command "system" to call the piped construct:</p>
  
  <pre><code>system %Q{curl -# http://example.com/archive.zip | curl -# http://example.com/fileupload.php -F "file=@-"}
  </code></pre>
  
  <p>I can see only one hashmark progress indicator in this case, so I think piping works as it should be, but I can see two consecutive hashmark progress indicator in this second case like this:</p>
  
  <pre><code>%x{curl -# http://example.com/archive.zip | curl -# http://example.com/fileupload.php -F "file=@-"}
  </code></pre>