This repository was archived by the owner on Jul 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Er suggestions nonmfs #304
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
68a84f4
Title renaming for parallelism
303d016
Copy suggestions - lesson 1
e59c294
Lesson 1 edits
310f3b4
Lesson 2 edits
c184172
Lesson 3 edits
6cd837c
Lessons 4-6 edits
7206acf
chore: update to review
dominguesgm 884bdae
chore: restore section on file upload in lesson 2
dominguesgm c07542f
chore: worked on last comment left
dominguesgm 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 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,23 @@ | ||
|
|
||
| ## IPFS: The InterPlanetary File System | ||
|
|
||
| [IPFS](https://ipfs.io/), or the InterPlanetary File System, is a peer-to-peer (P2P) networking protocol used to share data on the distributed web. As its full name suggests, you can think of IPFS as a file system, and it has some unique characteristics that make it ideal for safe, decentralized sharing. | ||
| [IPFS](https://ipfs.io/) is a peer-to-peer (P2P) networking protocol used to share data on the distributed web. You can think of it as a file system with some unique characteristics that make it ideal for safe, decentralized sharing. | ||
|
|
||
| If you haven't yet done so, we encourage you to check out our [Decentralized Data Structures tutorial](https://proto.school/#/data-structures/), where you can learn all about the decentralized web and how it compares to the web you're accustomed to. There you'll learn all about content addressing, cryptographic hashing, Content Identifiers (CIDs), and sharing with peers, all of which you'll need to understand to make the most of this tutorial on IPFS. | ||
| If you haven't yet done so, we encourage you to check out our [Decentralized Data Structures](https://proto.school/#/data-structures/) tutorial, to learn all about the decentralized web and how it compares to the one you're accustomed to. There you'll learn all about content addressing, cryptographic hashing, Content Identifiers (CIDs), and sharing with peers, all of which you'll need to understand to make the most of this tutorial. | ||
|
|
||
| ## File API vs DAG API | ||
| ## The File API vs the DAG API | ||
|
|
||
| You can store multiple types of data in the IPFS peer-to-peer data storage system. If you've gone through our [Decentralized Data Structures tutorial](https://proto.school/#/data-structures/), or even the [Blogging on the Decentralized Web tutorial](https://proto.school/#/blog), you already know you can store key value objects in the network. | ||
| You can store multiple types of data with IPFS. If you've gone through our Decentralized Data Structures tutorial — or even [Blogging on the Decentralized Web](https://proto.school/#/blog) — you already know you can store key value objects _(note: the term "key value objects" doesn't appear in these tutorials. rephrase?)_ in the network. | ||
|
|
||
| Storing key value objects is an interesting, but limited, use case. What if you want to share a picture of a kitten, how would you go about uploading that file into the network and providing a way for all your friends to see it? Or what about a funny video? How should the file be placed in the directed acyclic graph, in a single block or split into chunks? | ||
| Storing key value objects is an interesting, but limited, use case. What if you want to share a picture of a kitten? How would you upload it to the network and provide a way for your friends to see it? What about a larger file, such as a funny video? How should the file be placed in the Directed Acyclic Graph (DAG) — in a single block or split into chunks? | ||
|
|
||
| You can look at the File API as an abstraction layer above the DAG API, which takes care of getting files ready to be placed in the network, as well as knowing how to access them. The details of what this API actually does will be covered later in this tutorial. | ||
| You can think of the File API as an abstraction layer above the DAG API. The File API gets files ready to be placed in the network, and ensures that IPFS knows how to access them. The details of what this API actually does will be covered later in this tutorial. | ||
|
|
||
| ## Regular File API vs Mutable File System Files API | ||
| ## The Regular File API vs the MFS File API | ||
|
|
||
| You may have already read our [Mutable File System tutorial](https://proto.school/#/mutable-file-system), and if so you may be asking yourself "I've already learned how to use files on IPFS, how will this be any different?". | ||
| If you've read our [Mutable File System tutorial](https://proto.school/#/mutable-file-system), you may be thinking, "I've already learned how to use files on IPFS. How will this be any different?" | ||
|
|
||
| The Mutable File System (MFS) provides a File API which was built with the purpose of replicating file system operations that you are probably familiar with, such as `mkdir`, `ls`, `cp`, among others. However, the way that content is addressed in IPFS makes it an immutable file system. The address to a file or directory depends on its contents and, as such, modifying a file, or adding a new file to a directory, will result in an entirely new address for it. | ||
| The Mutable File System (MFS) provides a File API designed to replicate familiar file-system operations such as `mkdir`, `ls`, `cp`, and others. _(note: I feel like a logical link might help here, which points out that these operations rely upon consistent addressing, or something. As a visual designer, i can't quite put my finger on it, though! :D)_ However, the way that content is addressed in IPFS makes it an immutable file system. The address to a file or directory depends on its contents, so any change to a file — or new file added to a directory — will result in an entirely new address for the directory. | ||
|
|
||
| Therefore, despite being very useful, the abstraction the Mutable File System provides hides some of the inner workings of IPFS. The Regular File API we will discuss in this tutorial is a more barebones approach of using files in IPFS, not providing as much functionality through powerful abstractions as MFS, but helping you understand what you are actually doing in the file system. | ||
| Although MFS is very useful, the abstraction it provides hides some of the inner workings of IPFS. The Regular File API _(q: Is this the official name of the API, or is it simply "File API"? If "Regular" is part of the name, we may want to add that to the tutorial title. If not, "regular" should be lowercase in all places.)_ we will discuss here is instead a "bare bones" approach to managing files in IPFS. It trades the powerful abstractions of MFS for a scheme which helps you understand what is actually happening in the file system. | ||
|
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,22 @@ | ||
| Now that we've learned how to put some files on your IPFS node, we need to learn how can use their addresses ([CID's](https://proto.school/#/data-structures/04)) to get their content. If your familiar with UNIX style commands, you probably know `cat`. The IPFS File API provides a function with that same name to achieve the same purpose, that is, get the contents of a file. | ||
| Now that we've learned how to put some files onto your IPFS node, we can use their addresses ([CID's](https://proto.school/#/data-structures/04)) to get their content. If you're familiar with UNIX style commands, you probably know `cat`. The IPFS File API also provides a `cat` function for the same purpose: to get the contents of a file. | ||
|
|
||
| ## Using `cat` | ||
|
|
||
| When we want to get the contents of a file in IPFS, we call the `cat` function: | ||
| To get the contents of a file in IPFS, we call the `cat` function: | ||
|
|
||
| ```javascript | ||
| await ipfs.cat(ipfsPath, [options], [callback]) | ||
| ``` | ||
|
|
||
| The IPFS path can take several formats, you can read about them in the [File API documentation](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#cat). In this lesson, we will use the simplest form, which is the `hash` string present in the objects we receive from the calling the `ipfs.add` function. | ||
| The IPFS path can take several formats (you can read about them in the [File API](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#cat) documentation). In this lesson, we will use the simplest one: the `hash` string present in the objects we receive when the `ipfs.add` function is called. | ||
|
|
||
| The returned data comes in the form of an `Buffer`. If the file you uploaded is a plain text file, for example a `.txt`, you can read the contents of the file by calling `result.toString('utf8')`. | ||
| The returned data comes in the form of an `Buffer`. If you uploaded a plain text file (such as a `.txt`), you can read the contents of the file by calling `result.toString('utf8')`. | ||
|
|
||
| For example, if you have the `CID` to a text file whose contents you want to read you can do this: | ||
| So if you have the `CID` to a text file whose contents you want to read, you can do this: | ||
|
|
||
| ```javascript | ||
| let bufferedContents = await ipfs.cat(cid) // returns a buffer | ||
| let contents = bufferedContents.toString('utf8') // a string | ||
| ``` | ||
|
|
||
| When you're ready to try this in the real world, you should note that `cat` method can result in heavy memory usage based on the contents of the file being read. You might want to explore the [catReadableStream](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#catreadablestream) or [catPullStream](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#catpullstream) methods instead. | ||
| When you're ready to try this in the real world, you should note that the `cat` method can result in heavy memory usage, depending on the contents of the file being read. If you find this to be the case, you might want to explore the [catReadableStream](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#catreadablestream) or [catPullStream](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#catpullstream) methods instead. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| Now that we have uploaded some files into a directory in our IPFS node, let's learn how we can check the contents of a directory. If you use the terminal frequently, you're familiar with the `ls` command. Well, the Files API provides you with an `ls` function to achieve the same purpose. | ||
| Now that we've uploaded some files into a directory in our IPFS node, let's learn how we can check the contents of a directory. If you use the terminal frequently, you're familiar with the `ls` command. Well, the Files API provides you with an `ls` function to achieve the same purpose. | ||
|
|
||
| Calling `ls` looks like this: | ||
|
|
||
| ```javascript | ||
| await ifps.ls( ipfsPath ) | ||
| ``` | ||
|
|
||
| Where path can take multiple formats, the simplest being a pure `CID`. More information on the formats of the ipfs path can be found in the [ls section of the Files API](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#ls). | ||
| Where path can take multiple formats, the simplest being a pure `CID`. More information on the formats of the ipfs path can be found in the [`ls` section](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#ls) of the Files API. | ||
|
|
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
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.
@ericronne do you think we should remove this? Given this would be a begginer-oriented tutorial, I think it would be useful to explain the file upload functionality of the coding exercise
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.
Sure, good call @dominguesgm 👍