A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://richardschneider.github.io/net-ipfs-engine/articles/filesystem.html below:

IPFS file system

The official name is UnixFS. It allows files and directories of any size to be added and retrieved from IPFS via the FileSystem API and Object API.

Files

A file has a unique content id (CID) which is the cryptographic hash of the content; see CID concept for background information. The file's content is not just the file's data but is encapsulated with a protocol buffer encoding of the Merkle DAG and UnixFS Data.

Adding a file

AddAsync is used to add a stream of data to IPFS. It returns a FileSystemNode which describes the added the data. Of particular import is its CID. The helper methods AddTextAsync and AddFileAsync are also available.

All the Add methods accept options to control how the data is added to IPFS.

var fsn = await ipfs.FileSystem.AddTextAsync("hello world");
Console.WriteLine((string)fsn.Id)

// Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD
Reading a file

ReaFileAsync is used to read a stream of data from IPFS. It returns a Stream containing just the file's data NOT the protocol buffer encoded data.

string path = "Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD";
using (var stream = await ipfs.FileSystem.ReadFileAsyc(path))
{
    // Do something with the data
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4