Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 97be250

Browse files
committed
Update instructions in README
1 parent b452338 commit 97be250

File tree

1 file changed

+33
-92
lines changed

1 file changed

+33
-92
lines changed

examples/file-feed/README.md

Lines changed: 33 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Tutorial - Synchronize and distribute folders with files.
1+
# Example - Exchange files between Desktop and Browser
22

33
**WIP**
44

5-
## Run
5+
## Run - TEMP INSTRUCTIONS
66

77
1. Run a go-ipfs daemon with a WS address and --enable-pubsub-experiment flag, with API at port 5001
88
2. Run `node src/ff-cli/bin.js add hello package.json`
@@ -14,17 +14,18 @@ Note that the run order is important, running the ff-cli other way round won't w
1414

1515
## Coming up
1616

17-
> Welcome! This tutorial will guide you through building a web application for file distribution, using React, OrbitDB (a distributed key-value store) and libp2p PubSub. You will learn how to distribute content and how to synchronize state in a distributed way.
17+
> Welcome! This example will guide you through building a web application for file distribution, using React, OrbitDB (a serverless, distributed database) and libp2p PubSub. You will learn how to distribute content and how to synchronize state in a distributed way.
1818
1919
There are a couple of caveats:
2020

2121
- js-ipfs currently doesn't support DHT peer discovery, the peer from which you are fetching data should be within the reach (local or in public IP) of the browser node.
2222
- We need to use a signalling server to establish the WebRTC connections, this won't be necessary as soon as libp2p-relay gets developed
2323
- [full go-ipfs interop is not complete yet, blocked by an interop stream multiplexer](https://github.com/ipfs/js-ipfs/issues/721). You can, however, fetch content from go-ipfs through js-ipfs.
24+
- This app was created with create-react-app which provides its own build script. The caveat is that it doesn't allow us to use custom webpack config files which we need to shim `zlib` with `browserify-zlib-next`. As a workaround, we copy a custom webpack config file to `node_modules/react-scripts/config/` in a postinstall step.
2425

2526
That being said, we will explain throughout this tutorial to circunvent the caveats and once they are fixed, we will update the tutorial as well.
2627

27-
# Application diagram
28+
## Application diagram
2829

2930
```sh
3031

@@ -66,53 +67,35 @@ That being said, we will explain throughout this tutorial to circunvent the cave
6667
└───────────┘
6768
```
6869

69-
This app, file feed, will use OrbitDB over IPFS/libp2p PubSub to synchronize the latest state of feed, then using IPFS primitives to fetch and distribute the files. IPFS is using libp2p, the networking stack of IPFS, that enables IPFS to work in the Browser and in Node.js by swapping its building blocks, supporting multiple transports while keeping the same API.
70+
This app, file exchange, will use OrbitDB, IPFS and libp2p PubSub to synchronize the latest state of a file feed, then using IPFS primitives it fetched and distributes the files. IPFS is using libp2p, the networking stack of IPFS, that enables IPFS to work in the Browser and in Node.js by swapping its building blocks, supporting multiple transports while keeping the same API.
7071

71-
## Check out the final state
72+
## Quick Start
7273

73-
If you just want to check out what is the final state of how this application will look like, go to the complete folder, install the dependencies and run it.
74+
If you just want to check out the app, go to the complete folder, install the dependencies and run it.
7475

7576
```sh
76-
> cd complete
77-
> npm install
78-
> npm start
79-
# open your browser (Chrome or Firefox) in http://localhost:12345
77+
cd complete
78+
npm install
79+
npm start
80+
# open your browser (Chrome or Firefox) in http://localhost:3000
8081
```
8182

8283
You should get something like this:
8384

8485
`TODO: Insert final screenshot here`
8586

86-
## Step-by-step instructions
8787

88-
`TODO`
88+
## Step-by-step instructions
8989

90-
--------------------------------------
91-
`needs refactor`
9290
### Start a go-ipfs daemon
9391

94-
1. Install go-ipfs from master (TODO: link).
92+
1. Install go-ipfs from [master](https://github.com/ipfs/go-ipfs#build-from-source).
9593

96-
2. Run `ipfs init`
94+
2. Run `IPFS_PATH=$HOME/.file-exchange ipfs init`
9795

98-
3. Edit your IPFS config file, located at `~/.ipfs/config`
96+
3. Run `IPFS_PATH=$HOME/.file-exchange ipfs config Addresses.Swarm "[\"/ip4/0.0.0.0/tcp/9999/ws\"]" --json`
9997

100-
4. Add a Websocket listener address to `Addresses.Swarm`. It should look like this after editing:
101-
```
102-
"Addresses": {
103-
"API": "/ip4/127.0.0.1/tcp/5001",
104-
"Gateway": "/ip4/0.0.0.0/tcp/8080",
105-
"Swarm": [
106-
"/ip4/0.0.0.0/tcp/4001",
107-
"/ip4/0.0.0.0/tcp/9999/ws"
108-
]
109-
},
110-
```
111-
112-
5. Start the go-ipfs daemon with:
113-
```
114-
ipfs daemon
115-
```
98+
5. Start the go-ipfs daemon: `IPFS_PATH=$HOME/.file-exchange ipfs daemon --enable-pubsub-experiment`
11699

117100
6. You should see the Websocket address in the output:
118101
```
@@ -126,78 +109,36 @@ Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
126109
Daemon is ready
127110
```
128111

129-
If you see address like `Swarm listening on /ip4/127.0.0.1/tcp/9999/ws`, it means all good!
112+
If you see an address like `Swarm listening on /ip4/127.0.0.1/tcp/9999/ws`, it means **all good**!
130113

131-
### Start an InterPlanetary File Exchange daemon
132-
133-
1. Install the project's dependencies:
134-
```
135-
npm install
136-
```
137-
138-
2. Start the browser app with:
139-
```
140-
npm start
141-
```
114+
In a new terminal window, run `IPFS_PATH=$HOME/.file-exchange ipfs id` and note the first address in the `Addresses` field. It should look something like this: `/ip4/127.0.0.1/tcp/9999/ws/ipfs/QmZGH8GeASSkSZoNLPEBu1MqtzLTERNUEwh9yTHLEF5kcW`. **You'll need this address later**.
142115

143-
This will open the app in your browser at http://localhost:3000/.
116+
### Run File Exchange App
144117

145-
3. In the browser app, open a file exchange feed url, eg. http://localhost:3000/hello-world.
118+
**NOTE!**
119+
Before running the following command, you'll need to go to the root directory of `js-ipfs/` and run `npm install` to install all the dependencies. After you've done that, continue with the steps here.
146120

147-
4. Start the Node.js ipfe-daemon with:
121+
Install the project's dependencies:
148122
```
149-
node ipfe-daemon hello-world
150-
```
151-
152-
The first argument after `ipfe-daemon` is the name of the file exchange feed.
153-
154-
5. In the browser app, open the Peers view by clicking on "Searching for peers..." or "1 peer". You will see which peers you're connected to.
155-
156-
6. Now go back to the terminal and find the Websocket multiaddress of your go-ipfs daemon by running:
157-
```
158-
ipfs id
159-
```
160-
161-
This will output all the address your go-ipfs daemon is listening at. Find the one with `ws` in it, and the port you added to the go-ipfs configuration file. It looks something like this:
162-
```
163-
/ip4/127.0.0.1/tcp/9999/ws/ipfs/QmZGH8GeASSkSZoNLPEBu1MqtzLTERNUEwh9yTHLEF5kcW
123+
npm install
164124
```
165125

166-
7. Copy the address and paste it into the "Connect" input field in the browser app and press "Connect".
167-
168-
8. You should now see the two IPFS instances connected. You can verify it by observing the Peer view in the browser app and running the following command in the terminal:
126+
Start the browser app with:
169127
```
170-
ipfs swarm peers
128+
npm start
171129
```
172130

173-
### Add files to InterPlanetary File Exchange
131+
This will open the app in your browser at http://localhost:3000/. Open a file exchange feed by appending the feed name to the url, eg. http://localhost:3000/hello-world.
174132

175-
1. Add a file by running:
176-
```
177-
node ipfe-add hello-world ipfe-add.js
178-
```
133+
In the browser app, open the Peers view by clicking on "Searching for peers..." and enter the go-ipfs address you got fom `ipfs id` earlier into the input field and press connect. You should now see that address in the list of peers.
179134

180-
You should see the following output:
135+
Go back to the terminal and run the file exchange CLI tool:
181136
```
182-
Starting...
183-
Swarm listening on /libp2p-webrtc-star/ip4/127.0.0.1/tcp/9090/ws/ipfs/QmYRSN9BdRU5oYM1ryAWF518ogv8SkwZyux4aEWpxoaYZA
184-
IPFS node is ready
185-
New peers for 'hello-world':
186-
QmRNhXuS78LtUVLdJUJKmeLfE7K64CGBmwCiXY1sgJ6NaV
187-
------------------------------
188-
File | Hash | Size | Mime Type
189-
------------------------------
190-
ipfe-add.js | Qmdp8yhkyNGeqEYpkpqAm7duYqsEiJUi3KXfUFuUcyR2GR | 2588 | application/javascript
137+
node src/cli/bin add hello-world package.json
191138
```
192139

193-
Note that the multihash at the end of the swarm address will be different.
194-
195-
6. Once you see the output above, it means the file was added successfully!
196-
197-
7. Now go back to the browser app and observe the file in the list of files.
198-
199-
8. Click the file to open it.
140+
You should now see `package.json` in the browser app! Click it to view its contents.
200141

201-
9. You have successfully added a file in go-ipfs and downloaded it to the browser.
142+
**That's it!**
202143

203-
You can also add files to the browser app by dragging and dropping them. Once you do so, you should see the updated file list in the terminal running `ipfe-daemon`.
144+
Play around with the browser app, drag and drop files into it, run `node src/cli/bin` to see what else you can do with the CLI tool and have fun!

0 commit comments

Comments
 (0)