title: read data from a url and stream it back to client with ruby on rails
body: <p>I'm still new to Ruby and Rails so please excuse my question if the answer is obvious.  I have an application running with a controller called <code>bucket</code> which when passed an <code>id</code> connects to a non-routable subnet (10.0.0.xx) and returns data assuming some conditions are met.  I'm currently using the <code>send_data</code> method in the <code>bucket</code> controller but since this expects a local file I'm reading the contents of the url into a string and then returning that.  </p>
  
  <p>This is good enough for very small files but for large binaries it's too slow.  What I really want to be able to do is stream the data back using /bucket as a proxy.</p>
  
  <p>Here is the code from the controller I'm currently using:</p>
  
  <pre><code>fileName = "somename.dat"        
  content = open(link) {|f| f.read() }
  send_data content, :disposition=&gt;'attachment', :filename=&gt;fileName
  </code></pre>
  
  <p>I was hoping someone may have some advice on how to improve this.  Ideally, I could read the data in chunks and return it as I received it.</p>