Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Created August 6, 2012 17:06
Show Gist options
  • Save heapwolf/3276659 to your computer and use it in GitHub Desktop.
Save heapwolf/3276659 to your computer and use it in GitHub Desktop.
streams/piped
var nano = require('nano');
var request = require('request');
var spawn = require('child_process').spawn;
var server = nano('http://127.0.0.1:5984');
var createDbStream = server.db.create('pipe');
createDbStream.on('end', function () {
var db = server.use('pipe');
request
.get('http://nodejs.org/logo.png')
.pipe(db.attachment.insert('nodejs', 'logo.png', null, 'image/png'));
spawn('open', ['http://127.0.0.1:5984/pipe/nodejs/logo.png']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment