aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index 3803281..9da761e 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -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)