Develop a utility on GraalVM

Volodymyr Gubarkov
CML Team
Published in
6 min readMay 14, 2019

Image result for GraalVM

Problem definition

From time to time I need to share files over a local network for instance with a project colleague.

There are a lot of solutions for this — Samba / FTP / scp. You can simply upload the file to a publicly accessible place like Google Drive, attach it to a task in Jira or even send as email.

But all this is to some extent inflexible, sometimes it requires preliminary setup and has its limitations (for example the maximum size of the attachment).

And you want something more lightweight and flexible.

I always admired Linux for letting me quickly build a practical solution using only built-in tools.

Say, I often solved the problem mentioned above using the system python with the following one-liner:

$ python3 -mhttp.server
Serving HTTP on port 8000 ...

This command starts the web server in the current folder and allows you to get a list of files through the web interface and download them. You can find more similar tricks here:

There are several inconveniences though. Now to transfer the download link to your colleague you need to know your network IP address.

For this you can just do:

$ ifconfig -a

And then from the received list of network interfaces select the appropriate one and manually compile a link like http://IP:8000. Now it’s ready to be shared.

The second inconvenience — this server is single threaded. Thus while one of your colleagues is downloading the file the other one will not even be able to see the list of files.

Thirdly — it is inflexible. If you need to transfer only one file it will be unnecessary to open the entire folder i.e. you will have to perform such gestures (and don’t forget to clean up the garbage afterwards):

$ mkdir tmp1
$ cp tmp1
$ cd tmp1
$ python3 -mhttp.server

The fourth inconvenience — there is no simple way to download the entire contents of the folder.

To transfer the contents of the folder a technique called tar pipe is usually used.