Home Android Transfer Files Between Computers And Mobile Devices By Scanning QR Codes
Transfer Files Between Computers And Mobile Devices By Scanning QR Codes

Transfer Files Between Computers And Mobile Devices By Scanning QR Codes

By sk
1439 Views

File transfer between a Computer and a mobile can be done in various methods and using various protocols. Today, we will see a whole new, different approach. This guide explains how to transfer files between computers and mobile devices by scanning QR codes. Yes, you read that right! Say hello to Qrcp, formerly known as Qr-filetransfer, a simple command line file transfer application used to send and receive files over WiFi between a Linux system and a mobile phone by scanning a QR code, without leaving the Terminal.

When sending files, Qrcp will bind a web server to the address of your WiFi network interface card on a random port and create a handler for it. The default handler will serve the content and exit the program once the transfer is complete. Similarly, when receiving files, qrcp serves an upload page and handles the transfer.

Qrcp is a free, and open source program written in Go programming language and is released under MIT license.

Install Qrcp on Linux

Qrcp can installed in multiple ways. Install Qrcp in Linux using any one of the following methods.

Install Qrcp with Golang

First, install Go programming language in your Linux system as described in the following link.

After installing Golang, run the following command to install Qrcp in your linux system:

$ go get github.com/claudiodangelis/qrcp

Install Qrcp from binaries

Download the latest Qrcp archive file from the releases page. As of writing this guide, the latest version was 0.7.0.

$ wget https://github.com/claudiodangelis/qrcp/releases/download/0.7.0/qrcp_0.7.0_linux_x86_64.tar.gz

Extract the downloaded archive using commad:

$ tar xf qrcp_0.7.0_linux_x86_64.tar.gz

Move the binary file to your $PATH:

$ sudo mv qrcp /usr/local/bin

Finally, set executable permission:

$ sudo chmod +x /usr/local/bin/qrcp

Please note that the last step is optional. You don't have to make it executable. In this case, the file will became executable after you've moved it to your path.

Install Qrcp using package managers

Qrcp is available in AUR.

You can install it using any AUR helpers, for example Yay.

$ yay -S qrcp

Or,

$ yay -S qrcp-bin

Qrcp is also available as .deb and .rpm files. Go to the releases page and download the suitable version for your distro.

If you are on Debian-based systems, download the .deb installation file from the releases page and install it like below.

$ sudo apt install gdebi
$ sudo gdebi qrcp_0.7.0_linux_x86_64.deb

On RPM-based systems, such as CentOS, RHEL, download the .rpm file from releases page and install it like below:

$ sudo dnf install qrcp_0.7.0_linux_x86_64.rpm

Or,

$ sudo rpm -ivh qrcp_0.7.0_linux_x86_64.rpm

Once installed, confirm if Qrcp is working by running this command:

$ qrcp version
qrcp 0.7.0 [date: 2020-10-08T13:30:56Z]

Transfer Files Between Computers And Mobile Devices Using Qrcp By Scanning QR Codes

Transferring files between computers and mobile with Qrcp is quite easy!

For the purpose of this guide, I will be using Ubuntu 20.04 LTS desktop system and an Android Tablet PC.

Make sure you have installed a QR code reader application on your mobile phone. There are plenty of QR code readers available for Android. Please do a quick web search and install any QR code reader of your choice on your mobile.

Send files from computer to mobile using Qrcp

First, let us see how to send a file from a Linux system to mobile.

I am going to send an image file from my Ubuntu desktop to the tablet PC using command:

$ qrcp ostechnix.png

When you launch Qrcp for the first time, it will scan your system to find the number of available WiFi network interfaces in your system. If there are more than one suitable WiFi cards available, Qrcp will ask you to choose one to transfer files. In my case, I chose wireless interface i.e. wlp9s0. Hit ENTER key to accept the wireless interface. Qrcp will remember this choice and will not ask next time.

Use the arrow keys to navigate: ↓ ↑ → ← 
? Choose interface: 
  ▸ wlp9s0 (192.168.225.37)
    virbr0 (192.168.122.1)
    mpqemubr0 (10.39.86.1)
    any (0.0.0.0)

You will now see a QR code in your Terminal as shown below.

✔ wlp9s0 (192.168.225.37)
Scan the following URL with a QR reader to start the file transfer:
http://192.168.225.37:41377/send/7jwi
█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ ██▄ ▄███▄▄█▀▄▄█ ▄▄▄▄▄ ████
████ █   █ █ ▀▀ ██▄█▄▀██▄█ █   █ ████
████ █▄▄▄█ █ ██▄█   █▀▄█ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄█▄▀▄▀▄█ █ █▄▄▄▄▄▄▄████
████ ▀  ▄▄▄█▀▀▀███▄ ▄█▀ █▀   ▄▄█▀████
████▀█▄ ▀▄▄ ██  ▀█▀█▀▀ ▀▀▄▀ ▀██▀█████
████▀▀▄▄▄▀▄▄▀█▄▀█▀▀▄ █▄▄▀ ▀▄▄▄ █▀████
████ █▀  █▄▀▀ █ █ ▄▄ ▄█ █ ▀█ █▄▀█████
████ █▀ ██▄▄▄▄█ ▀█▄▄█▄▄█ █▄█▀▀ █▀████
████ █▄█▀▄▄▄█ █ ▄█▀█▀▄▀▀▀█▄█ ▄▄▀█████
████▄█▄▄▄▄▄▄ ▄▄▀▀▀▀▄ ██▀ ▄▄▄ ▀   ████
████ ▄▄▄▄▄ █▀▄█▀█ ▄▄▄ ▀  █▄█ ▄▄█▀████
████ █   █ █  ▀▀▄█▄▄ ▄▀    ▄ ▄█▀█████
████ █▄▄▄█ █▄▄█▀  ▄██▄▀▄ ▀█▄▀██ █████
████▄▄▄▄▄▄▄█▄█▄█▄▄▄▄█████▄█▄█████████
█████████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Send files from computer to mobile using Qrcp
Send files from computer to mobile using Qrcp

Now, open the QR code reader app in your mobile phone and scan the QR code shown in Linux computer's terminal. After the scanning the QR code, you will see the Download URL in your mobile phone. Just click it to download the file.

Scan the QR code with a QR reader app from the mobile to start the file transfer
Scan the QR code with a QR reader app from the mobile to start the file transfer

The file will be downloaded in the default Download folder in your mobile.

File is successfully downloaded in the mobile
File is successfully downloaded in the mobile

You can also send multiple files as well:

$ qrcp file1 file2

And a whole folder can be sent like below:

$ qrcp ~/Documents/

If the size of the file is big, just zip it and send with --zip flag:

$ qrcp --zip movie.mp4

Receive files from mobile to computer using Qrcp

To send a file to your computer from your mobile device, run the following command in your Linux system's Terminal:

$ qrcp receive

You will see QR code in the Terminal:

Scan the following URL with a QR reader to start the file transfer:
http://192.168.225.37:35221/receive/3xiz
█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ ██  █ ▀ ▄██  ▄█ ▄▄▄▄▄ ████
████ █   █ █ ▀█▄▀ ▄▀▄█▄▄██ █   █ ████
████ █▄▄▄█ █  ▄█ ██▄▀▄▀█▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ █ ▀▄█▄█ █ ▀▄█▄▄▄▄▄▄▄████
████ ▀▄▄▄ ▄▀█▄ █ ▀█▄▄█▀▀█▀   ▄▄█▀████
████ ▄▄▀▀█▄ █▄▀▄▄ ▄▄▄▀ ▀▀▄▀ ▀██▀█████
██████▀█▄▄▄▀█ ▄█ █▄▄ █▀▄▀ ▀▄▄▄ █▀████
████▄ █  █▄▄█    █▀██▄█ █ ▀█ █▄▀█████
████ ▀▀▀█▀▄▀▀▀▀█▄▀▀  ▄ █ █▄█▀▀ █▀████
████ █ ▀▀█▄ █ █▀  ▄▄▀▄▀▀▀█▄█ ▄▄▀█████
████▄█▄██▄▄█ ▄ ▄▀█▄▄▀██▀ ▄▄▄ ▀   ████
████ ▄▄▄▄▄ █▀█▄█▄█▀▄ ▄▀  █▄█ ▄▄█▀████
████ █   █ █   █▀▀▀ ▄▄▄    ▄ ▄█▀█████
████ █▄▄▄█ █▄██▄█▄██▀▄▀▄ ▀█▄▀██ █████
████▄▄▄▄▄▄▄█▄▄▄▄███▄▄████▄█▄█████████
█████████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Receive files from mobile to computer using Qrcp
Receive files from mobile to computer using Qrcp

Open the QR code reader in the mobile device and scan the above QR code. Click the URL to upload the files from your mobile:

Scan QR code from the mobile to start file transfer
Scan QR code from the mobile to start file transfer

A new browser window will open in your mobile. Choose the files that you want to send from your mobile to your Computer and click Transfer button:

Choose files from the mobile to send to your Computer
Choose files from the mobile to send to your Computer

Upon successful file transfer, you will see the following message on your mobile device:

Files are sent successfully from mobile to computer
Files are sent successfully from mobile to computer

On your Linux terminal, you will see the following message after file transfer is completed:

Transferring file:  /home/sk/IMG-20201017-WA0002.jpg
/home/sk/IMG-20201017-WA0002.jpg[===============================================]  99.74% 0s
File transfer completed
Files are received from mobile to computer
Files are received from mobile to computer

As you can see, the file is downloaded in the current directory. If you want to receive the files to a specific directory, use the --output flag:

$ qrcp receive --output=~/Downloads

In this case, all files will be downloaded in the ~/Downloads directory.

Qrcp options

Qrcp requires zero configuration. By default, Qrcp will work out of the box without any prior configuration. You can, however, tweak the functionality of Qrcp in certain ways with the help of Qrcp parameters. For example, you can use specific port instead of a random port, specify location of config file, use specific network interface card for file transfer, use custom URLs for sending/receiving files, use FQDN instead of IP address, print the QR code in browser, keep the server alive, and securely transfer files via HTTPS etc.

Configure Qrcp

The default configuration file is stored in $HOME/.qrcp.json. Qrcp will read and use the parameters defined in this file while transferring files.

You can view the currently configured parameters using cat command:

$ cat $HOME/.qrcp.json
{
    "fqdn": "",
    "interface": "wlp9s0",
    "port": 0,
    "keepAlive": false,
    "path": "~/Desktop",
    "secure": false,
    "tls-key": "",
    "tls-cert": ""
}

We can configure the Qrcp default parameters as per our liking by running the following command:

$ qrcp config

Choose the suitable wireless network interface to use for file transfer:

? Choose interface: 
    mpqemubr0 (10.39.86.1)
  ▸ wlp9s0 (192.168.225.37)
    virbr0 (192.168.122.1)
    any (0.0.0.0)

If you don't see the network interfaces for some reason, use the following command instead:

$ qrcp --list-all-interfaces config

Enter the fully qualified name (FQDN):

✔ Choose fully-qualified domain name: sk.ostechnix.example

Choose random port:

✔ Choose port, 0 means random port: 8080

If you want to use random port, simply press 0 (zero).

Enter destination path to save the files/folders:

✔ Choose path, empty means random: ~/Downloads

By default, Qrcp will save the received files/folders in the current directory.

Choose if you want to keep the server alive after file transfer:

? Should the server keep alive after transferring?: 
  ▸ No
    Yes

Select the appropriate option if you want to securely transfer file:

? Should files be securely transferred with HTTPS?: 
  ▸ No
    Yes

If you choose "Yes", you will have to enter your TLS certificate path and TLS certificate key.

After updating the configuration file, the default configuration will be updated with the new values.

Configuration updated:
{
  "fqdn": "sk.ostechnix.example",
  "interface": "wlp9s0",
  "port": 8080,
  "keepAlive": false,
  "path": "~/Downloads",
  "secure": false,
  "tls-key": "",
  "tls-cert": ""
}

Qrcp will use these new values while transferring files.

You can also manually use custom parameters instead of existing parameters defined in the config file.

Use custom port

Qrcp will use any random available port while sending and receiving files between your Computer and the mobile device. If you want to use a certain port, for example 8080, while transferring files, use --port or -p flag:

$ qrcp --port 8080 file.txt

Specify location of config file

As stated earlier, the default config file is stored in $HOME/.qrcp.json. If you want to use a config file stored in different location, specify its path using the --config flag:

$ qrcp --config ~/Downloads/qrcp.json file.txt

Use specific WiFi interface for file transfer

If there are more than one suitable WiFi interfaces available in your system, you can use a specific WiFi interface for file transfer using the --interface (or -i) flag:

$ qrcp -i wlp9s0 file.txt

Assign specific path for URLs

Qrcp uses the following URL formats by default to send and receive files:

  • send - http://{ip address}:{port}/send/{random path}
  • receive - http://{ip address}:{port}/receive/{random path}

If you want to use a specific path for URLs, instead of random path, use the --path flag:

$ qrcp --path=abcd file.txt

Now, the resulting URL will be:

$ http://{ip address}:{port}/send/abcd

Use FQDN instead of IP address

By default, Qrcp will use your Linux system's IP address in the URL. If you want to use fully qualified named instead of the IP address in the URL, use the --fqdn (or -d) flag:

$ qrcp --fqdn ostechnix.example -i wlp9s0 -p 8080 file.txt

Print QR code in browser

Qrcp will generate the QR code in the Terminal. If you want to print the QR outside of the Terminal window, use the --browser flag.

$ qrcp --browser file.txt

This command will still print the QR code in the Terminal, but also it will display the QR code in the new window of your default web browser.

Keep the server alive

Once the file transfer is completed, the connection will be closed automatically. So the other devices can't access the that file/folder anymore. If you want to transfer same file/folder to multiple devices, keep the server alive using the --keep-alive flag:

$ qrcp --keep-alive file.txt

Getting help

To view the list of available sub-commands and the flags, run:

$ qrcp --help
Usage:
  qrcp [flags]
  qrcp [command]

Available Commands:
  completion  Generate completion script
  config      Configure qrcp
  help        Help about any command
  receive     Receive one or more files
  send        Send a file(s) or directories from this host
  version     Print version number and build information.

Flags:
  -b, --browser               display the QR code in a browser window
  -c, --config string         path to the config file, defaults to $HOME/.qrcp
  -d, --fqdn string           fully-qualified domain name to use for the resulting URLs
  -h, --help                  help for qrcp
  -i, --interface string      network interface to use for the server
  -k, --keep-alive            keep server alive after transferring
  -l, --list-all-interfaces   list all available interfaces when choosing the one to use
      --path string           path to use. Defaults to a random string
  -p, --port int              port to use for the server
  -q, --quiet                 only print errors
  -s, --secure                use https connection
      --tls-cert string       path to TLS certificate to use with HTTPS
      --tls-key string        path to TLS private key to use with HTTPS
  -z, --zip                   zip content before transferring

Use "qrcp [command] --help" for more information about a command.

Resource:

Related read:

Featured image by Gerd Altmann from Pixabay.

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More