diff options
Diffstat (limited to 'lib/app.js')
-rw-r--r-- | lib/app.js | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -379,6 +379,13 @@ App.prototype.addBlobPrivate = function (cb) { } App.prototype.getBlob = function (id, key) { + if (!key) { + var m = /^(.*)\?unbox=(.*)$/.exec(id) + if (m) { + id = m[1] + key = m[2] + } + } if (!key) return this.sbot.blobs.get(id) if (typeof key === 'string') key = new Buffer(key, 'base64') return pull( @@ -387,6 +394,16 @@ App.prototype.getBlob = function (id, key) { ) } +App.prototype.getHasBlob = function (id, cb) { + id = id.replace(/\?unbox=.*/, '') + if (!this.sbot.blobs) return cb(new TypeError('missing ssb-blobs plugin')) + if (!this.sbot.blobs.size) return cb(new TypeError('missing blobs.size method')) + this.sbot.blobs.size(id, function (err, size) { + if (err) return cb(err) + cb(null, size != null) + }) +} + App.prototype.pushBlob = function (id, cb) { console.error('pushing blob', id) this.sbot.blobs.push(id, cb) |