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

Commit b0a7cd8

Browse files
committed
Fix dependencies, update instructions in README, fix webpack build process, cleanups
1 parent ead9181 commit b0a7cd8

File tree

6 files changed

+386
-7
lines changed

6 files changed

+386
-7
lines changed

examples/ipfm/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ build
1313
.DS_Store
1414
.env
1515
npm-debug.log
16+
17+
# orbit-db
18+
orbit-db

examples/ipfm/README.md

+126-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,130 @@
22

33
**WIP**
44

5+
InterPlanetary File Exchange enables you to share files with others via IPFS.
6+
7+
IPFE was built to demonstrate interoperability between the go-ipfs and js-ipfs (browser and Node.js) instances.
8+
9+
## Requirements
10+
11+
- Node.js >= v4.x
12+
- Npm >= v3.x
13+
14+
## Step-by-step Instructions
15+
16+
### Start a go-ipfs daemon
17+
18+
1. Install go-ipfs from master (TODO: link).
19+
20+
2. Run `ipfs init`
21+
22+
3. Edit your IPFS config file, located at `~/.ipfs/config`
23+
24+
4. Add a Websocket listener address to `Addresses.Swarm`. It should look like this after editing:
25+
```
26+
"Addresses": {
27+
"API": "/ip4/127.0.0.1/tcp/5001",
28+
"Gateway": "/ip4/0.0.0.0/tcp/8080",
29+
"Swarm": [
30+
"/ip4/0.0.0.0/tcp/4001",
31+
"/ip4/0.0.0.0/tcp/9999/ws"
32+
]
33+
},
34+
```
35+
36+
5. Start the go-ipfs daemon with:
37+
```
38+
ipfs daemon
39+
```
40+
41+
6. You should see the Websocket address in the output:
42+
```
43+
Initializing daemon...
44+
Swarm listening on /ip4/127.0.0.1/tcp/4001
45+
Swarm listening on /ip4/127.0.0.1/tcp/9999/ws
46+
Swarm listening on /ip4/192.168.10.38/tcp/4001
47+
Swarm listening on /ip4/192.168.10.38/tcp/9999/ws
48+
API server listening on /ip4/127.0.0.1/tcp/5001
49+
Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
50+
Daemon is ready
51+
```
52+
53+
If you see address like `Swarm listening on /ip4/127.0.0.1/tcp/9999/ws`, it means all good!
54+
55+
### Start an InterPlanetary File Exchange daemon
56+
57+
1. Install the project's dependencies:
58+
```
59+
npm install
60+
```
61+
62+
2. Start the browser app with:
63+
```
64+
npm start
65+
```
66+
67+
This will open the app in your browser at http://localhost:3000/.
68+
69+
3. In the browser app, open a file exchange feed url, eg. http://localhost:3000/hello-world.
70+
71+
4. Start the Node.js ipfe-daemon with:
72+
```
73+
node ipfe-daemon hello-world
74+
```
75+
76+
The first argument after `ipfe-daemon` is the name of the file exchange feed.
77+
78+
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.
79+
80+
6. Now go back to the terminal and find the Websocket multiaddress of your go-ipfs daemon by running:
81+
```
82+
ipfs id
83+
```
84+
85+
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:
86+
```
87+
/ip4/127.0.0.1/tcp/9999/ws/ipfs/QmZGH8GeASSkSZoNLPEBu1MqtzLTERNUEwh9yTHLEF5kcW
88+
```
89+
90+
7. Copy the address and paste it into the "Connect" input field in the browser app and press "Connect".
91+
92+
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:
93+
```
94+
ipfs swarm peers
95+
```
96+
97+
### Add files to InterPlanetary File Exchange
98+
99+
1. Add a file by running:
100+
```
101+
node ipfe-add hello-world ipfe-add.js
102+
```
103+
104+
You should see the following output:
105+
```
106+
Starting...
107+
Swarm listening on /libp2p-webrtc-star/ip4/127.0.0.1/tcp/9090/ws/ipfs/QmYRSN9BdRU5oYM1ryAWF518ogv8SkwZyux4aEWpxoaYZA
108+
IPFS node is ready
109+
New peers for 'hello-world':
110+
QmRNhXuS78LtUVLdJUJKmeLfE7K64CGBmwCiXY1sgJ6NaV
111+
------------------------------
112+
File | Hash | Size | Mime Type
113+
------------------------------
114+
ipfe-add.js | Qmdp8yhkyNGeqEYpkpqAm7duYqsEiJUi3KXfUFuUcyR2GR | 2588 | application/javascript
115+
```
116+
117+
Note that the multihash at the end of the swarm address will be different.
118+
119+
6. Once you see the output above, it means the file was added successfully!
120+
121+
7. Now go back to the browser app and observe the file in the list of files.
122+
123+
8. Click the file to open it.
124+
125+
9. You have successfully added a file in go-ipfs and downloaded it to the browser.
126+
127+
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`.
128+
5129
## Dev & Run
6130
```
7131
npm install
@@ -12,12 +136,10 @@ See `package.json` for more dev scripts.
12136

13137
## Tutorial
14138

139+
**TODO**
140+
15141
This project was bootstrapped with [Create React App](https://github.com./facebookincubator/create-react-app).
16142

17143
```
18144
npm install ipfs-daemon orbit-db --save
19145
```
20-
21-
## Notes
22-
23-
"uglify-js": "github:mishoo/UglifyJS2#harmony",

0 commit comments

Comments
 (0)