The new file

  • Create a folder named 1121 on the desktop, create file. TXT in the folder, enter data in the file, save the file and exit

    pwd/Users/CHY/Desktoppwd /Users/CHY/Desktoppwd/Users/CHY/Desktop mkdir 1121 cd1121/cd 1121/cd1121/ vi file.txt $ cat File. TXT ha ha, why only I am unhappy

  • When entering the file, use I to start typing

  • After entering, press Exc to exit editing, shift+ colon, and enter wq to save the changes

View the IPFS help command

$ ipfs help USAGE ipfs - Global p2p merkle-dag filesystem. ipfs [--config=<config> | -c] [--debug=<debug> | -D] [--help=<help>] [-h=<h>] [--local=<local> | -L] [--api=<api>] <command> ... SUBCOMMANDS BASIC COMMANDS init Initialize ipfs local configuration add <path> Add a file to IPFS cat <ref> Show IPFS object data get <ref> Download IPFS objects ls <ref> List links from an object refs <ref> List hashes of links from an object DATA STRUCTURE COMMANDS block Interact with raw blocks in the datastore object Interact with raw dag nodes files Interact with objects as if they were a unix filesystem dag Interact with IPLD documents (experimental) ADVANCED COMMANDS daemon Start a long-running daemon process mount Mount an IPFS read-only mountpoint resolve Resolve any type of  name name Publish and resolve IPNS names key Create and list IPNS name keypairs dns Resolve DNS links pin Pin objects to local storage repo Manipulate the IPFS repository stats Various operational stats p2p Libp2p stream mounting filestore Manage the filestore (experimental) NETWORK COMMANDS id Show info about IPFS peers bootstrap Add or remove bootstrap peers swarm Manage connections to the p2p network dht Query the DHT for values or peers ping Measure the latency of a connection diag Print diagnostics TOOL COMMANDS config Manage configuration version Show ipfs version information update Download and apply go-ipfs updates commands List all available commandsCopy the code

Add the file to the IPFS node

$ipfs add file. TXT added QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T file. TXT file $cat. TXT haha, $ipfs cat QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T haha, analyzing the specific issues specific analysisCopy the code

  • TXT will be added to the current ipfs node. And for the file. TXT file to generate a unique hash ` ` QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T, if you want to see the data of local ipfs node, Can see through ipfs cat QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T.

  • Ipfs cat QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T and command ipfs cat file. TXT content is the same

  • But through the http://ipfs.io/ipfs/QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T data access, can’t access, because this data is stored in our local, only to be released to the public on a cluster of the IPFS can access.

Synchronize the nodes

  • Run the ipfs daemon command

    $ ipfs daemon Initializing daemon… Adjusting current ulimit to 2048… Successfully raised the file descriptor limit to 2048. The Swarm listening on/ip4 111.196.246.151 / TCP / 3637 Swarm listening on / ip4 127.0.0.1 / TCP / 4001 Swarm listening on/ip4 169.254.170.167 / TCP / 4001 Swarm listening on/ip4/192.168.0.107 / TCP / 4001 Swarm listening on /ip6/::1/ TCP /4001 API Server listening on /ip4/127.0.0.1/ TCP /5001 Gateway (readonly) Server listening On /ip4/127.0.0.1/ TCP /8080 Daemon is ready

  • fromIPFSWeb view data, enter in browserIpfs. IO/ipfs/Qmbrev…link

Create a directory to store files

  • Using the command ipfs cat QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T liyc1215 view added to the ipfs network file. The content of the TXT file

  • You can also use the ipfs command to create a folder under the ipfs root directory and move or copy the file. TXT file to the folder we created.

  • Cp does not change the file hash, mv changes the hash address

  • Ipfs files mkdir /1122 The new 1122 folder must contain a slash (/)

    ipfsfilesmkdir/1122ipfs files mkdir /1122ipfsfilesmkdir/1122 ipfs files cp /ipfs/QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T /1122/file.txt ipfsfilesls/1122ipfs files ls / 1122ipfsfilesls/1122 Ipfs files ls /1122/file. TXT $ipfs files read /1122/file. TXT

Add a directory

An entire directory can be uploaded using ipfs add-r

$ ipfs add -r ipfs-tutorial/
added QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc ipfs-tutorial/contactme.txt
added QmfKdWsguobA3aDPvSxLB3Bq4HMKyqKSgFr2NFUuVH8n31 ipfs-tutorial/eth-fabric.png
added QmXe8jTxTh5MZP6BK5cnj19mXNTKVMzNyUJZUHuYyr5dk1 ipfs-tutorial/gongzhonghao.png
added QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek ipfs-tutorial
Copy the code

  • QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek hash of a whole

  • TXT files can be viewed by using ipFS CAT hash, while files of other formats must be downloaded and converted. For example, the access code for the above eth-fabric.png file is

    ipfs get /ipfs/QmfKdWsguobA3aDPvSxLB3Bq4HMKyqKSgFr2NFUuVH8n31 -o eth-fabric.png

  • The hash before the file name is their own hash value

Access the contactme. TXT file data by path

  • If we are uploading a directory, there are several ways to access the data in the contactMe. TXT file.

    $ ipfs cat QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc

    $ ipfs cat /ipfs/QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc

    $ ipfs cat /ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek/contactme.txt

View IPFS network data using Hash

Access the directory: https://ipfs.io/ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek by directory access files: https://ipfs.io/ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek/contactme.txt via a file hash direct access to: https://ipfs.io/ipfs/QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxcCopy the code