Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fc40dba

Browse files
committedOct 11, 2015
fix files.write
1 parent 1f810a9 commit fc40dba

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed
 

‎src/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,15 @@ function IpfsAPI (host_or_multiaddr, port) {
247247
return requestAPI('files/rm', path, opts, null, cb)
248248
},
249249
read: argCommand('files/read'),
250-
write: argCommand('files/write'),
250+
// write: argCommand('files/write'),
251+
write: function (pathDst, files, opts, cb) {
252+
if (typeof (opts) === 'function' && cb === undefined) {
253+
cb = opts
254+
opts = {}
255+
}
256+
257+
return requestAPI('files/write', pathDst, opts, files, cb)
258+
},
251259
mv: argCommand('files/mv')
252260
}
253261
}

‎test/test.js

+5-15
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,6 @@ describe('ipfs node api', function () {
293293
})
294294
})
295295

296-
// [x] files.mkdir
297-
// [x] files.cp
298-
// [x] files.ls
299-
// [x] files.stat
300-
// [x] files.read
301-
// [~] files.write
302-
// [x] files.mv
303-
// [x] files.rm
304-
305-
// added on the add test 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
306-
307296
// --- files api tests
308297

309298
it('files.mkdir', function (done) {
@@ -381,16 +370,17 @@ describe('ipfs node api', function () {
381370
})
382371
})
383372

384-
/*
385373
it('files.write', function (done) {
386374
this.timeout(20000)
387375

388-
ipfs.files.write(['/test-folder/test-file', 'yellow'], function (err) {
389-
if (err) throw err
376+
ipfs.files.write('/test-folder/test-file', new Buffer('bananas'), function (err) {
377+
console.log('->', err)
378+
if (err) {
379+
throw err
380+
}
390381
done()
391382
})
392383
})
393-
*/
394384

395385
it('files.mv', function (done) {
396386
this.timeout(20000)

0 commit comments

Comments
 (0)
This repository has been archived.