Skip to content

Instantly share code, notes, and snippets.

@twilson63
Last active January 17, 2019 15:54
Show Gist options
  • Save twilson63/1ea57bfc2923084ebccbdd2d6f3686b5 to your computer and use it in GitHub Desktop.
Save twilson63/1ea57bfc2923084ebccbdd2d6f3686b5 to your computer and use it in GitHub Desktop.
Sharing files with dat

Sharing Files with dat

The datproject is a p2p protocol that enables users to exchange information without having to use a centralized platform, as long as you have an internet connection, you can use the dat protocol.

In this post, we will walk through sharing files using the dat cli.

How to install the dat cli

First you will need NodeJS, you can download and install node from https://nodejs.org

Once installed, you can open up a terminal window or command prompt and run the following command:

npm install dat --global

If you get an error, go to the npm site to learn how to setup up node to install global packages. https://docs.npmjs.com/downloading-and-installing-packages-globally

Sharing some file

Now that dat is installed you are ready to share some files, lets create a simple file.

mkdir dat1
cd dat1
echo "Hello from dat" > hello.txt

Init your directory

dat share

You will be prompted to give it a title and description, maybe dat1 and Hello World.

You will see some out stating that you are ready to share:

Created empty Dat in /Users/twilson63/play/discovery-swarm-lab/dat1/.dat

Now you can add files and share:
* Run dat share to create metadata and sync.
* Copy the unique dat link and securely share it.

dat://93183d8223127c64ca...7e65

Now that you are ready to share your files, simple run:

dat share

And you are sharing your files using the dat hash key.

Get your files

On another computer you can retrieve your files by installing the dat cli with the same instructions above and running dat clone

dat clone [dat url] [folder name]

Finished

You have just transferred files from one computer to another.

If it did not work, then there is a chance you are on a network that does not support the distributed hash table, check out pinning services like https://hashbase.io that can be used to seed your files, or you can use your own server to seed the files as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment