For beginners: Free Upload and Download of Files to/from the IOTA Tangle

Roberto Rey
Coinmonks

--

Purpose of this program? It is NOT to have a way to store audio or video files on the Tangle. I had two things in mind. To show the potential of the IOTA Tangle. Most people think of IOTA as a “competitor” to Bitcoin, as a blockchain. BUT: there are only few interfaces between the two systems. The second thing I had in mind: there is the need to transfer data between entities (for example the settings of a process). Within a company, this is simple. But across borders, or companies, or organizations, or platforms, this is difficult and subject to problems. Storing data on a medium that is censorship resistant and immutable is of significant importance.

This is the audio file I uploaded to the Tangle. It is a voicemail somebody left me a while ago.

Purpose of this program: to upload and store audio files onto the IOTA Tangle.

This article assumes you have Python installed on your machine (I used a Raspberry Pi). To install python and/or use a terminal refer to any of my previous articles.

Contact me if you are stuck. Also please let me know if you see anything that needs improvement.

1. Activate IOTA

To communicate with the IOTA tangle you need to install the PyOTA library (https://github.com/iotaledger/iota.lib.py):

cd ~/

sudo apt-get install libffi-dev (to avoid the error: “failed building wheel for cryptography”)

sudo pip install pyota[ccurl]

git clone https://github.com/iotaledger/iota.lib.py.git

To test if the installation was successful (this will take around 10 minutes):

cd iota.lib.py

python setup.py test

2. Preparing the audio file to be uploaded

To upload an audio file you need to convert is to a Base64 String first. There are several web pages where you can do this. I used Base64.Guru (https://base64.guru/converter/encode/audio).

The result will look as follows:

3. The code to upload audio files

Copy and use the following program (I called it iota-audio.py):

There are three changes you need to make (they are all highlighted in the code):

  1. Insert your IOTA address
  2. Check that you are using the best Node
  3. Insert the Base64 String of your audio file
  4. Insert your Tag so you can bundle files (only the following characters are allowed: A…Z and only number 9)

You will need an IOTA address. For this I recommend installing the trinity wallet on your computer (https://trinity.iota.org) and get a new address that way.

Run the program:

python iota-audio.py

While the program is running you will see the following output:

Go to THETANGLE.ORG, insert your IOTA address and you will see all the transactions you generated. To check click on one of the transactions and you will see something like this:

The code to download audio files

Copy and use the following code (I called it iota-audio-download-read.py):

There are three changes you need to make (they are all highlighted in the code):

  1. Select a good IOTA node
  2. Insert your IOTA address
  3. Insert your Tag

Run the program:

python iota-audio-download.py

You will see the following output:

Highlight the output and copy it.

Use the following website to decode the base64 code to generate the audio file: https://base64.guru/converter/decode/audio. Paste the text into the Base64 field and click on “Decode Base64 to Audio”.

Error?

There are a few possible problems when trying to decode the data:

  • The Tag was not unique: when a few files were uploaded using the same TAG, then you will not be able to download the file. Solution: re-upload the file with a new TAG of build into the code a check on the time-stamp.
  • You copied more than needed (or less) from the terminal.

Get Best Software Deals Directly In Your Inbox

--

--