Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs-inactive/js-ipfs-http-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 718bddef9be9
Choose a base ref
...
head repository: ipfs-inactive/js-ipfs-http-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1f810a95db20
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 11, 2015

  1. fix rm -r bug

    daviddias committed Oct 11, 2015
    Copy the full SHA
    22d0d0e View commit details
  2. Copy the full SHA
    1f810a9 View commit details
Showing with 66 additions and 26 deletions.
  1. +34 −13 README.md
  2. +2 −2 src/index.js
  3. +30 −11 test/test.js
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -220,33 +220,54 @@ curl 'http://localhost:5001/api/v0/object/get?arg=QmYEqnfCZp7a39Gxrgyv3qRS4MoCTG

##### mkdir

bash:
`curl "http://localhost:5001/api/v0/files/mkdir?arg=%2F<folder name>`"

response: (it returns empty when successful)
```
```

javascript:
```JavaScript
ipfs.files.mkdir(<folderName>, function (err) {})
```

response: (it returns empty when successful)
```
```

##### cp

```JavaScript
ipfs.files.cp([<pathSrc>, <pathDst>], function (err) {})
```

##### ls

```JavaScript
ipfs.files.ls(<path>, function (err, res) {})
```

##### stat

```JavaScript
ipfs.files.stat(<path>, function (err, res) {})
```

##### rm

```JavaScript
ipfs.files.rm(<path>, [<options>], function (err) {})
```

For `rm -r` pass a options obj with `r: true`

##### read

```JavaScript
ipfs.files.read(<path>, function (err, res) {
if(res.readable) {
// Returned as a stream
res.pipe(process.stdout)
} else {
// Returned as a string
console.log(res)
}
})
```

##### write

##### mv
curl "http://localhost:5001/api/v0/files/mkdir?arg=%2Ffolder4"

```JavaScript
ipfs.files.mv([<pathSrc>, <pathDst>], function (err) {})
```
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -239,12 +239,12 @@ function IpfsAPI (host_or_multiaddr, port) {
ls: argCommand('files/ls'),
mkdir: argCommand('files/mkdir'),
stat: argCommand('files/stat'),
rm: function (key, value, opts, cb) {
rm: function (path, opts, cb) {
if (typeof (opts) === 'function') {
cb = opts
opts = {}
}
return requestAPI('config', [key, value], opts, null, cb)
return requestAPI('files/rm', path, opts, null, cb)
},
read: argCommand('files/read'),
write: argCommand('files/write'),
41 changes: 30 additions & 11 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -297,9 +297,9 @@ describe('ipfs node api', function () {
// [x] files.cp
// [x] files.ls
// [x] files.stat
// [ ] files.read
// [ ] files.write
// [ ] files.mv
// [x] files.read
// [~] files.write
// [x] files.mv
// [x] files.rm

// added on the add test 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
@@ -310,7 +310,6 @@ describe('ipfs node api', function () {
this.timeout(20000)

ipfs.files.mkdir('/test-folder', function (err) {
console.log('->', err)
assert(!err)
if (err) {
return done()
@@ -324,12 +323,12 @@ describe('ipfs node api', function () {

ipfs.files
.cp(['/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file'], function (err) {
assert(!err)
if (err) {
return done()
}
done()
})
assert(!err)
if (err) {
return done()
}
done()
})
})

it('files.ls', function (done) {
@@ -382,13 +381,33 @@ describe('ipfs node api', function () {
})
})

/*
it('files.write', function (done) {
this.timeout(20000)
ipfs.files.write(['/test-folder/test-file', 'yellow'], function (err) {
if (err) throw err
done()
})
})
*/

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

ipfs.files.mv(['/test-folder/test-file', '/test-folder/test-file2'], function (err) {
if (err) throw err
done()
})
})

// -

it('files.rm', function (done) {
this.timeout(20000)

// TODO fix the recursive qs value based on Jeromy input
ipfs.files.rm('/test-folder', { '-r': true }, function (err) {
ipfs.files.rm('/test-folder', { 'r': true }, function (err) {
assert(!err)
if (err) {
return done()