Setting up Safe for PUT/GET

These instructions are intended to be generic over any safe version and any testnet-name. Below you can replace <version> with the expected version, and <testnet-name> with the testnet you are trying to connect to.

Instructions and examples are provide for Linux, Mac and Windows.

Uploading/downloading

To upload and download (PUT and GET) data to the test network, you just need to install the safe binary on your operating system.

Linux and macOS

Installation

On Linux:

curl -so- https://raw.githubusercontent.com/maidsafe/safe_network/master/resources/scripts/install.sh | sudo bash

safe --version # should be <version> ## should be current version, see above

On macOS:

# switch to sudo shell
sudo su

# run install script
curl -so- https://raw.githubusercontent.com/maidsafe/safe_network/master/resources/scripts/install.sh | bash

# return to your own user profile
exit


safe --version # should be <version> ## should be current version, see above

All subsequent instructions are the same for both operating systems.

Join latest testnet

To join the latest testnet, download the contacts file and switch to the current testnet (change as appropriate).

safe networks add <testnet-name> https://sn-node.s3.eu-west-2.amazonaws.com/testnet_tool/<testnet-name>/network-contacts
safe networks switch <testnet-name>

Uploading

Linux upload both

Uploading a file
# Upload a file in your current directory
safe files put [filename]
e.g. safe files put examplePic.jpg

Uploading a container (a directory plus contents)
Choose a directory (e.g. /home/[yourUserName]/Pictures) or make a new one and add some files. Then cd to the parent directory (e.g. /home/[yourUserName]/) and run:
safe files put ./[directory] --recursive
e.g. safe files put ./Pictures --recursive

Downloading

Linux download

Downloading a file
Use safe cat safe://[address] > filename.txt to download a file:

Downloading container (directory plus contents)
safe files get safe://[address?v=version]

# For example this will download the container to your current directory. This is just an example, it's not live data)

safe files get safe://hyryyryikpk16oxay7wa1midtbkibxoec6eg4fsgd853gx5xuhs19ujmgzwnra?v=hc7xjae7f8o96xk9446gzyy13j9z7es47rpqdcu81iap61jdcu6no

Windows

Installation

Press the Windows key or click on the Start button and type “Powershell”. Then right click on the Windows Powershell entry on the menu and select Run as administrator.

Paste the following text into the terminal by right clicking on the bar at the top of the window, then select edit → paste:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/maidsafe/safe_network/main/resources/scripts/install.ps1'))

Now hit enter to run the install. If you have a previously installed binary, you’ll be asked if you want to overwrite it. Say yes. Now exit the session.

Start a new session without administrator privileges.

safe --version # should be <version> ## should be current version, see above

Join latest testnet

To join the latest testnet, download the contacts file and switch to the current testnet (change as appropriate).

safe networks add <testnet-name> https://sn-node.s3.eu-west-2.amazonaws.com/testnet_tool/<testnet-name>/network-contacts
safe networks switch <testnet-name>

Downloading

Downloading files
safe cat safe://address > filename
e.g.
safe cat safe://hygoygym7tsj5hhyyykd1aqpw3djxea6om6xku568ahm7hy7gfn6q5gy7xr > coast.jpg

Note: Problems have been reported with using PowerShell for downloading. If the downloaded file is unreadable try using cmd instead.

Downloading container (directory plus contents)
# For example this will download the container to your current directory. This is just an example, it's not live data)

safe files get safe://hyryyryikpk16oxay7wa1midtbkibxoec6eg4fsgd853gx5xuhs19ujmgzwnra?v=hc7xjae7f8o96xk9446gzyy13j9z7es47rpqdcu81iap61jdcu6no

Uploading

Uploading file
# Upload a file in your current directory
safe files put [filename]

e.g.
safe files put examplePic.jpg

Uploading a container (directory plus contents)
Choose a directory (e.g. /home/[yourUserName]/Pictures) or make a new one and add some files.

Then cd to the parent directory (e.g. C:\Users\[your username]\) and run:
safe files put .\[directory] --recursive
e.g.
safe files put .\Pictures --recursive

10 Likes

Can we remove the instructions for deleting the binary and clearing the ~/.safe directory please?

In the case of the binary, the install will overwrite it. The Windows install actually asks you if you want to overwrite (we could do this for Linux/macOS too).

It should only be necessary to remove the ~/.safe directory if we change the format of settings or something like that. In my opinion it would be good practice for us as a development team to try to become cognizant of breaking changes like this and try to have this in the commit messages and hence the changelog for the release. In my opinion, our users should be forewarned if they need to delete the configuration from one release to another. We should also try to be backward compatible if we could be. At this stage it’s probably not that important, but it will be after a general launch, so we may as well get in to the practice of doing it now.

7 Likes

Done - also added a note for Windows users about problems with PowerShell

6 Likes

Should there be something about “create a keypair for your CLI” noted too?

1 Like