Created
October 30, 2015 14:49
-
-
Save dignifiedquire/bc72721f5b96c7017188 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Eu@@F@,1 | |
j | |
#!tK#!tK2 | |
7c | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder" | |
Content-Type: multipart/mixed | |
2 | |
8a | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/add.js" | |
Content-Type: application/javascript | |
1d6 | |
'use strict' | |
var ipfs = require('../src')('localhost', 5001) | |
var f1 = 'Hello' | |
var f2 = 'World' | |
ipfs.add([new Buffer(f1), new Buffer(f2)], function (err, res) { | |
if (err || !res) return console.log(err) | |
for (var i = 0; i < res.length; i++) { | |
console.log(res[i]) | |
} | |
}) | |
ipfs.add(['./files/hello.txt', './files/ipfs.txt'], function (err, res) { | |
if (err || !res) return console.log(err) | |
for (var i = 0; i < res.length; i++) { | |
console.log(res[i]) | |
} | |
}) | |
2 | |
8a | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/cat.js" | |
Content-Type: application/javascript | |
161 | |
'use strict' | |
var ipfs = require('../src')('localhost', 5001) | |
var hash = [ | |
'QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w', | |
'QmY9cxiHqTFoWamkQVkpmmqzBrY3hCBEL2XNu3NtX74Fuu' | |
] | |
ipfs.cat(hash, function (err, res) { | |
if (err || !res) return console.log(err) | |
if (res.readable) { | |
res.pipe(process.stdout) | |
} else { | |
console.log(res) | |
} | |
}) | |
2 | |
82 | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/files" | |
Content-Type: multipart/mixed | |
2 | |
87 | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/files/hello.txt" | |
Content-Type: text/plain | |
6 | |
Hello | |
2 | |
86 | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/files/ipfs.txt" | |
Content-Type: text/plain | |
5 | |
IPFS | |
2 | |
8f | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/ipfs-add.js" | |
Content-Type: application/javascript | |
130 | |
#!/usr/bin/env node | |
var ipfs = require('../src')('localhost', 5001) | |
var files = process.argv.slice(2) | |
ipfs.add(files, {recursive: true}, function (err, res) { | |
if (err || !res) return console.log(err) | |
for (var i = 0; i < res.length; i++) { | |
console.log('added', res[i].Hash, res[i].Name) | |
} | |
}) | |
2 | |
89 | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/ls.js" | |
Content-Type: application/javascript | |
1a1 | |
'use strict' | |
var ipfs = require('../src')('localhost', 5001) | |
var hash = ['QmdbHK6gMiecyjjSoPnfJg6iKMF7v6E2NkoBgGpmyCoevh'] | |
ipfs.ls(hash, function (err, res) { | |
if (err || !res) return console.log(err) | |
res.Objects.forEach(function (node) { | |
console.log(node.Hash) | |
console.log('Links [%d]', node.Links.length) | |
node.Links.forEach(function (link, i) { | |
console.log('[%d]', i, link) | |
}) | |
}) | |
}) | |
2 | |
8e | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e | |
Content-Disposition: file; filename="test-folder/version.js" | |
Content-Type: application/javascript | |
8e | |
'use strict' | |
var ipfs = require('../src')('localhost', 5001) | |
ipfs.commands(function (err, res) { | |
if (err) throw err | |
console.log(res) | |
}) | |
2 | |
28 | |
--879a0747-bbc5-4ea8-9ea0-ce86984ada6e-- | |
0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment