title: node.js expressjs proxy static from amazon s3
body: <p>When a request comes in for a page, eg <code>app.get("/")</code> I want to return a static HTML page from amazon s3. I know I can request it from S3 and then send it, but that seems slow. Is there anyway to tell the requester to get the file from s3 directly without changing the url?</p>
  
  <p>Thanks.</p>
  
  <p>Failing that, what's the fastest way to serve the file from s3?</p>
  
  <p>This tutorial shows writing the file first</p>
  
  <p><a href="http://www.hacksparrow.com/node-js-amazon-s3-how-to-get-started.html" rel="nofollow">http://www.hacksparrow.com/node-js-amazon-s3-how-to-get-started.html</a></p>
  
  <pre><code>// We need the fs module so that we can write the stream to a file
  var fs = require('fs');
  // Set the file name for WriteStream
  var file = fs.createWriteStream('slash-s3.jpg');
  knox.getFile('slash.jpg', function(err, res) {
      res.on('data', function(data) { file.write(data); });
      res.on('end', function(chunk) { file.end(); });
  });
  </code></pre>
  
  <p>Is there a way to send the file without writing it first? Writing it seems awfully slow.</p>