Skip to content

Commit b0ccd2e

Browse files
committedAug 18, 2014
4.0.0 - use abstract-blob-store 2.x API
1 parent 4cd9b91 commit b0ccd2e

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed
 

‎index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ Blobs.prototype.createWriteStream = function(options, cb) {
8282
function handleUploadResponse() {
8383
return concat(function(body) {
8484
var response = JSON.parse(body)
85-
self.addProperty(response.id, 'hash', response.md5Checksum, function(err, resp, props) {
85+
self.addProperty(response.id, 'key', response.md5Checksum, function(err, resp, props) {
8686
if (err) return cb(err)
8787
if (resp.statusCode > 299) return cb(new Error(JSON.stringify(props)))
88-
response.hash = response.md5Checksum
88+
response.key = response.md5Checksum
8989
response.size = +response.fileSize
9090
if (process.env['DEBUG']) debug('createWriteStream done', JSON.stringify(response))
9191
cb(null, response)
@@ -115,7 +115,7 @@ Blobs.prototype.createReadStream = function(opts) {
115115
var self = this
116116
var duplex = duplexify()
117117
debug('createReadStream', JSON.stringify(opts))
118-
self.get(opts.hash, function(err, file) {
118+
self.get(opts.key, function(err, file) {
119119
if (err) return duplex.destroy(err)
120120
if (!file) return duplex.destroy(new Error('Blob not found'))
121121
var req = self.request({
@@ -130,7 +130,7 @@ Blobs.prototype.createReadStream = function(opts) {
130130

131131
Blobs.prototype.exists = function(opts, cb) {
132132
var self = this
133-
self.get(opts.hash, function(err, file) {
133+
self.get(opts.key, function(err, file) {
134134
if (err) return cb(err)
135135
cb(null, !!file)
136136
})
@@ -184,7 +184,7 @@ Blobs.prototype.request = function(opts, cb) {
184184

185185
Blobs.prototype.get = function(hash, cb) {
186186
var self = this
187-
var query = "properties has { key='hash' and value='" + hash + "' and visibility='PRIVATE' } and trashed = false"
187+
var query = "properties has { key='key' and value='" + hash + "' and visibility='PRIVATE' } and trashed = false"
188188
var reqOpts = {
189189
contentType: 'application/json',
190190
query: '?' + formEncoder.encode({q: query}),
@@ -202,7 +202,7 @@ Blobs.prototype.get = function(hash, cb) {
202202
Blobs.prototype.remove = function(opts, cb) {
203203
var self = this
204204

205-
self.get(opts.hash, function(err, file) {
205+
self.get(opts.key, function(err, file) {
206206
if (err) return cb(err)
207207
var reqOpts = {
208208
method: 'DELETE',

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "google-drive-blobs",
3-
"version": "3.1.0",
3+
"version": "4.0.0",
44
"description": "a simple content-addressable streaming blob store API on top of google drive",
55
"main": "index.js",
66
"scripts": {
@@ -18,7 +18,7 @@
1818
"through2": "^0.5.1"
1919
},
2020
"devDependencies": {
21-
"abstract-blob-store": "^1.1.1"
21+
"abstract-blob-store": "^2.0.1"
2222
},
2323
"repository": {
2424
"type": "git",

‎readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ returns a writable stream that you can pipe data to.
2626

2727
### blobs.createReadStream(opts)
2828

29-
opts should be `{hash: md5}`
29+
opts should be `{key: md5}`
3030

3131
returns a readable stream of data for the first file in your drive whose md5 checksum matches the `md5` argument
3232

@@ -36,7 +36,7 @@ gets google drive metadata for the first file in your drive whose md5 checksum m
3636

3737
### blobs.remove(opts, cb)
3838

39-
opts should be `{hash: md5}`
39+
opts should be `{key: md5}`
4040

4141
deletes file by md5
4242

‎test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test('uploads a blob', function(t) {
3838
var ws = blobs.createWriteStream({filename: 'test.js'}, function(err, resp) {
3939
t.false(err, 'should not error')
4040
if (err) console.error(err)
41-
t.equal(resp.hash, testmd5)
41+
t.equal(resp.key, testmd5)
4242
t.end()
4343
})
4444

@@ -58,7 +58,7 @@ test('gets blob metadata by md5', function(t) {
5858
test('gets a blob', function(t) {
5959
var blobs = gdb(tokens)
6060

61-
var ws = blobs.createReadStream({hash: testmd5})
61+
var ws = blobs.createReadStream({key: testmd5})
6262

6363
ws.on('error', function(e) {
6464
t.error(e)
@@ -74,7 +74,7 @@ test('gets a blob', function(t) {
7474
test('deletes a blob', function(t) {
7575
var blobs = gdb(tokens)
7676

77-
var ws = blobs.remove({hash: testmd5}, function(err) {
77+
var ws = blobs.remove({key: testmd5}, function(err) {
7878
t.false(err, 'snould not err')
7979
blobs.get(testmd5, function(err, file) {
8080
t.false(err, 'should not err')

0 commit comments

Comments
 (0)
Please sign in to comment.