title: How to stream from one SFTP to another SFTP using python and pysftp
body: <p>I want to transfer files from one SFTP server to another.</p>
  
  <p>I don't want to write locally, and I don't want to read the whole file into memory.</p>
  
  <p>Pysftp has <code>getfo</code> and <code>putfo</code> methods.  </p>
  
  <p>But <code>getfo</code> doesn't give you a reader -- it gives just writes to an opened fileobj.</p>
  
  <p>I essentially want to pipe <code>getfo</code> to some file-like that can be read from, so I can provide this as the reader for <code>putfo</code>, to send to target.</p>
  
  <p>Pseudocode:</p>
  
  <pre><code>buffer_obj = SomeBufferedIOReader()
  source_sftp.getfo('/remote/path.txt.gz', buffer_obj)
  target_sftp.putfo('/target/path.txt.gz', buffer_obj) # streaming commences
  </code></pre>
  
  <p>If I was doing this in bash I would create a fifo file, write to the fifo asynchronously, and then upload from that file.  When the file was uploaded, the fifo would be exhausted and process would complete.  Not sure how to do the equivalent in python.</p>