This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implementing the new interfaces #1086
Merged
Merged
Changes from 13 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
878496a
refactor: first clean up, add stubs, move things around
daviddias 5cf7d76
feat .add .addReadableStream and .addPullStream
daviddias ca5d71a
.get getReadableStream and getPullStream implemented
daviddias f0b11ac
ls is done too!
daviddias 292e3e5
docs: update browser-browserify
daviddias 8d62b0a
docs: update browser-script-tag
daviddias b9f13e1
docs: update browser-video-streaming
daviddias 6cd3ae4
docs: update browser webpack
daviddias 4193dea
update ipfs 101
daviddias 6701f09
update exchange files example
daviddias c292b5a
wip
daviddias ef4bf22
fix large file tests
daviddias e9821ce
update example to pull-streams
daviddias 136a5e0
core tests all passing
daviddias cbdb828
concat buffers once
daviddias 59c4483
run ALL tests on CI
daviddias 8ebc043
make sure CI runs all tests
daviddias c3dd81c
always use pull-streams for cli ipfs files add
daviddias a006ba7
refactor cli daemon tests, find that 3 of them do not pass
daviddias 62b39cc
fix gateway tests
daviddias 35248d4
more fixes
daviddias 1993a2f
chore
daviddias a33b5d5
.add in the example works again, just missing .get
daviddias 09ea377
update the example
daviddias f5e7561
chore: update deps
daviddias 91f7a4e
chore: update deps
daviddias 2372c90
wip
daviddias 01dad53
fix
daviddias 4130b9c
skip dht
daviddias fb1b1dd
fix test script in package.json
daviddias 13a5fb8
apply cr
daviddias 54e2427
avoid passing empty array if path does not exist for ls
daviddias ef1680c
fix linting
daviddias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,33 +4,17 @@ | |
<title>IPFS in the Browser</title> | ||
<script src="https://unpkg.com/ipfs/dist/index.min.js"></script> | ||
<script type="text/javascript"> | ||
const repoPath = 'ipfs-' + Math.random() | ||
const node = new Ipfs({ repo: 'ipfs-' + Math.random() }) | ||
|
||
// Create an IPFS node | ||
const node = new Ipfs({ | ||
init: false, | ||
start: false, | ||
repo: repoPath | ||
}) | ||
|
||
// Init the node | ||
node.init(handleInit) | ||
|
||
function handleInit (err) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
node.start(() => { | ||
console.log('Online status: ', node.isOnline() ? 'online' : 'offline') | ||
node.on('ready', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
console.log('Online status: ', node.isOnline() ? 'online' : 'offline') | ||
|
||
document.getElementById("status").innerHTML= 'Node status: ' + (node.isOnline() ? 'online' : 'offline') | ||
document.getElementById("status").innerHTML= 'Node status: ' + (node.isOnline() ? 'online' : 'offline') | ||
|
||
// You can write more code here to use it. Use methods like | ||
// node.files.add, node.files.get. See the API docs here: | ||
// https://github.com/ipfs/interface-ipfs-core/tree/master/API | ||
}) | ||
} | ||
// You can write more code here to use it. Use methods like | ||
// node.files.add, node.files.get. See the API docs here: | ||
// https://github.com/ipfs/interface-ipfs-core/tree/master/API | ||
}) | ||
</script> | ||
</head> | ||
<body> | ||
|
@@ -44,32 +28,24 @@ <h2>Some suggestions</h2> | |
<p>Try adding a new file:</p> | ||
|
||
<code style="display:block; white-space:pre-wrap; background-color:#d7d6d6"> | ||
node.files.add(new node.types.Buffer('Hello world!'), (err, res) => { | ||
if (err || !res) { | ||
node.files.add(new node.types.Buffer('Hello world!'), (err, filesAdded) => { | ||
if (err) { | ||
return console.error('Error - ipfs files add', err, res) | ||
} | ||
|
||
res.forEach((file) => console.log('successfully stored', file)) | ||
filesAdded.forEach((file) => console.log('successfully stored', file.hash)) | ||
}) | ||
</code> | ||
|
||
<p>You can cat that same file. If you used the exact same string as above ('Hello world!') you should have an hash like this: 'QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY'</p> | ||
|
||
<code style="display:block; white-space:pre-wrap; background-color:#d7d6d6"> | ||
node.files.cat('QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY', function (err, stream) { | ||
var res = '' | ||
|
||
stream.on('data', function (chunk) { | ||
res += chunk.toString() | ||
}) | ||
|
||
stream.on('error', function (err) { | ||
console.error('Error - ipfs files cat ', err) | ||
}) | ||
node.files.cat('QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY', function (err, data) { | ||
if (err) { | ||
return console.error('Error - ipfs files cat', err, res) | ||
} | ||
|
||
stream.on('end', function () { | ||
console.log('Got:', res) | ||
}) | ||
console.log(data.toString()) | ||
}) | ||
</code> | ||
</body> | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,7 @@ class App extends React.Component { | |
function create () { | ||
// Create the IPFS node instance | ||
|
||
node = new IPFS({ | ||
repo: String(Math.random() + Date.now()) | ||
}) | ||
node = new IPFS({ repo: String(Math.random() + Date.now()) }) | ||
|
||
node.on('ready', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
console.log('IPFS node is ready') | ||
|
@@ -47,25 +45,15 @@ class App extends React.Component { | |
}) | ||
}) | ||
|
||
node.files.add([Buffer.from(stringToUse)], (err, res) => { | ||
if (err) { | ||
throw err | ||
} | ||
node.files.add([Buffer.from(stringToUse)], (err, filesAdded) => { | ||
if (err) { throw err } | ||
|
||
const hash = res[0].hash | ||
const hash = filesAdded[0].hash | ||
self.setState({added_file_hash: hash}) | ||
|
||
node.files.cat(hash, (err, res) => { | ||
if (err) { | ||
throw err | ||
} | ||
let data = '' | ||
res.on('data', (d) => { | ||
data = data + d | ||
}) | ||
res.on('end', () => { | ||
self.setState({added_file_contents: data}) | ||
}) | ||
node.files.cat(hash, (err, data) => { | ||
if (err) { throw err } | ||
self.setState({added_file_contents: data}) | ||
}) | ||
}) | ||
} | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using
.once
instead of `.on´?