From f104723fe4fe0598f19ac3dacfaacfda93374f7e Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 18 Feb 2017 22:59:38 -0500 Subject: Implement uploading blobs in composer --- lib/app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index faed5fc..5d8af70 100644 --- a/lib/app.js +++ b/lib/app.js @@ -5,6 +5,8 @@ var pkg = require('../package') var u = require('./util') var pull = require('pull-stream') var ssbAvatar = require('ssb-avatar') +var hasher = require('pull-hash/ext/ssb') +var multicb = require('multicb') var Serve = require('./serve') var Render = require('./render') @@ -94,6 +96,19 @@ App.prototype.publish = function (content, cb) { } } +App.prototype.addBlob = function (cb) { + var done = multicb({pluck: 1, spread: true}) + var hashCb = done() + var addCb = done() + done(function (err, hash, add) { + cb(err, hash) + }) + return pull( + hasher(hashCb), + this.sbot.blobs.add(addCb) + ) +} + function getMsgWithValue(sbot, id, cb) { sbot.get(id, function (err, value) { if (err) return cb(err) -- cgit v1.2.3