You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basics/js/js-ipfs.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,11 @@ description: "A simple walkthrough of how to perform basic IPFS operations using
5
5
6
6
# IPFS in JavaScript
7
7
8
-
This guide aims to walk you through the basics of using IPFS with JavaScript. JS-IPFS is one of multiple [IPFS implementations](../ipfs-implementations.md). You will learn how to install and spawn a node using the available libraries, as well as add, retrieve, read, and remove files. If you are unsure about the meaning of some terms, check out the [glossary](../concepts/glossary.md).
8
+
This guide will walk you through the basics of using IPFS with JavaScript. JS-IPFS is one of multiple [IPFS implementations](../ipfs-implementations.md). You will learn how to install and spawn a node using the available libraries, and add, retrieve, read, and remove files. If you are unsure about the meaning of some terms, check out the [glossary](../concepts/glossary.md).
9
9
10
10
::: tip Environment
11
11
12
-
All instructions and examples shown here were performed and tested on an M1 Mac. However, the IPFS commands are the same on Linux, macOS, and Windows. You will need to know how to navigate your computer's directories from within the CLI. If you're unsure how to use the CLI, we recommend learning how before continuing with this guide.
12
+
All instructions and examples shown here were performed and tested on an M1 Mac. However, the IPFS commands are the same on Linux, macOS, and Windows. You will to navigate your computer's directories from within the CLI. If you're unsure how to use the CLI, we recommend learning how before continuing with this guide.
13
13
14
14
:::
15
15
@@ -29,7 +29,7 @@ To use the CLI on your machine, globally install the `ipfs` Node.js package:
29
29
npm i --location=global ipfs
30
30
```
31
31
32
-
Alternatively, you can build the project from source. See the [JS-IPFS GitHub repository](https://github.com/ipfs/js-ipfs) for instructions.
32
+
Alternatively, you can build the project from the source. See the [JS-IPFS GitHub repository](https://github.com/ipfs/js-ipfs) for instructions.
33
33
34
34
:::
35
35
@@ -43,7 +43,7 @@ To use the IPFS core API, install the `ipfs-core` Node.js package:
43
43
npm i ipfs-core
44
44
```
45
45
46
-
Alternatively, you can build the project from source. See the [JS-IPFS GitHub repository](https://github.com/ipfs/js-ipfs) for instructions.
46
+
Alternatively, you can build the project from the source. See the [JS-IPFS GitHub repository](https://github.com/ipfs/js-ipfs) for instructions.
47
47
48
48
:::
49
49
@@ -55,13 +55,13 @@ Alternatively, you can build the project from source. See the [JS-IPFS GitHub re
55
55
56
56
::: tab ipfs-cli id="spawn-ipfs-cli"
57
57
58
-
1. To spawn a node using the CLI, simply start the daemon:
58
+
1. To spawn a node using the CLI, start the daemon:
59
59
60
60
```bash
61
61
jsipfs daemon
62
62
```
63
63
64
-
1. You should see an output similar to:
64
+
2. You should see an output similar to:
65
65
66
66
```shell
67
67
Initializing IPFS daemon...
@@ -79,11 +79,11 @@ Alternatively, you can build the project from source. See the [JS-IPFS GitHub re
79
79
Daemon is ready
80
80
```
81
81
82
-
1. You should be able to point to the [webpage](http://127.0.0.1:5002/webui) using the address output by the terminal `http://127.0.0.1:5002/webui`:
82
+
3. You should be able to point to the [webpage](http://127.0.0.1:5002/webui) using the address output by the terminal `http://127.0.0.1:5002/webui`:
83
83
84
84

85
85
86
-
1. If you are unable to connect to the API, ensure [cross-origin (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) requests are configured:
86
+
4. If you are unable to connect to the API, ensure [cross-origin (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) requests are configured:
@@ -158,7 +158,7 @@ Create a simple Node.js application to host the logic that will allow you to use
158
158
159
159
### Connect to IPFS
160
160
161
-
The JS-IPFS implementation is split into several Node.js modules. The following section shows examples of how you can use the HTTP client to connect to IPFS. For more information on the different modules, examine the [API Packages table](../../reference/js/api.md##packages)
161
+
The JS-IPFS implementation is split into several Node.js modules. The following section shows examples of using the HTTP client to connect to IPFS. For more information on the different modules, examine the [API Packages table](../../reference/js/api.md##packages)
162
162
163
163
:::: tabs
164
164
@@ -198,7 +198,7 @@ The library internally detects if your machine is running a local node.
198
198
npm i ipfs-client
199
199
```
200
200
201
-
2. Populate your `index.js` file with the following to create an instance of the HTTP API client:
201
+
1. Populate your `index.js` file with the following to create an instance of the HTTP API client:
202
202
203
203
```js{1,3-5}
204
204
import { create } from 'ipfs-client'
@@ -213,7 +213,7 @@ The library internally detects if your machine is running a local node.
213
213
214
214
This imports the client library and uses the `create()` function to define the server endpoints.
215
215
216
-
3. To connect to the endpoints, run the application:
216
+
1. To connect to the endpoints, run the application:
217
217
218
218
```bash
219
219
node index.js
@@ -231,29 +231,29 @@ Now you can start to add files using JS-IPFS to the IPFS network.
231
231
232
232
::: warning Section changes coming soon
233
233
234
-
As the JS-IPFS implementation goes through changes, the steps to add a file are likely to change. Please reference the [source packages](https://github.com/ipfs/js-ipfs) for the latest updates.
234
+
As the JS-IPFS implementation changes, some of these steps should be deemed conditional. Please reference the [source packages](https://github.com/ipfs/js-ipfs) for the latest updates.
235
235
236
236
:::
237
237
238
238
:::: tabs
239
239
240
240
::: tab ipfs-cli id="add-ipfs-cli"
241
241
242
-
1. In a new session, navigate to the directory you wish to add a file from. You can also specify the file path when using the cli to add a file.
243
-
1. The daemon uses an `ADD` method to request data from IPFS; `jsipfs add`. We will use a test file called `test.txt` to add through the jsipfs daemon.
242
+
1. In a new session, navigate to the directory from which you wish to add a file. You can also specify the file path when using the cli to add a file.
243
+
2. The daemon uses an `ADD` method to request data from IPFS; `jsipfs add`. We will use a test file called `test.txt` to add through the jsipfs daemon.
244
244
245
245
```bash
246
246
jsipfs add ./test.txt
247
247
```
248
248
249
-
1. You should obtain a result that verifies the file was added and returns the CID:
249
+
3. You should obtain a result that verifies the file was added and returns the CID:
1. The file has been added to the IPFS network and has given the file a CID. You can share this CID with anyone, and they can use it on their IPFS node to obtain the content you uploaded.
256
-
1. To view the file contents, navigate to the [webui](http://127.0.0.1:5002/webui) and provide the CID on the search bar. The UI will provide the file contents, similar to the following:
255
+
4. The file has been added to the IPFS network and has given the file a CID. You can share this CID with anyone, and they can use it on their IPFS node to obtain the content you uploaded.
256
+
5. To view the file contents, navigate to the [webui](http://127.0.0.1:5002/webui) and provide the CID on the search bar. The UI will provide the file contents, similar to the following:
257
257
258
258

259
259
@@ -424,7 +424,7 @@ Removing the content pin will remove a file from IPFS. In this section, we will
1. `test.txt` file is now unpinned, but it has not been removed from our node completely. To remove it completely, we need to run the [garbage collection](../../concepts/persistence##garbage-collection). The command will remove everything from your node that does not have a pin:
427
+
1. `test.txt` file is now unpinned, but it has not been removed from our node completely. To remove it completely, run the [garbage collection](../../concepts/persistence##garbage-collection). The command will remove everything from your node that does not have a pin:
428
428
429
429
```shell
430
430
jsipfs repo gc
@@ -439,7 +439,7 @@ Removing the content pin will remove a file from IPFS. In this section, we will
439
439
[...]
440
440
```
441
441
442
-
1. The target file has now been fully removed from your IPFS node and any other files that we did not pin. If the content that was just garbage collected was saved to your computer's local storage, it is still there. If you wish to remove the content from your computer's local storage, you will need to find where it is saved and delete it using the normal deletion method.
442
+
2. The target file has now been removed from your IPFS node and other files that were not pinned. If the content that was just garbage collected was saved to your computer's local storage, it is still there. If you wish to remove the content from your computer's local storage, you will need to find where it is saved and delete it using the normal deletion method.
0 commit comments