Skip to content

Instantly share code, notes, and snippets.

@streunerlein
Created May 24, 2012 23:20
Show Gist options
  • Save streunerlein/2784839 to your computer and use it in GitHub Desktop.
Save streunerlein/2784839 to your computer and use it in GitHub Desktop.
How to pipe attachments from couchdb - without losing nice caching effects [nano]
var couchconfig = {
hostname: "localhost"
}
var nano = require("./nano/nano.js")("http://" + couchconfig.hostname + ":5984"),
db = nano.use("nano-test"),
express = require("express");
var app = express.createServer();
app.get('/', function(req, res){
req.headers.host = couchconfig.host;
nano.request({
db: "nano-test",
doc: "test",
att: "latest-xkcd.png",
headers: req.headers
}).pipe(res);
});
app.listen(3000);
@streunerlein
Copy link
Author

Note, as of this date this example only works with the modified version of nano, where headers can be passed to nano.request()... (see https://github.com/streunerlein/nano)

A pull request to the original nano is in progress...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment