<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: claudio d'angelis</title>
    <description>The latest articles on DEV Community by claudio d'angelis (@claudiodangelis).</description>
    <link>https://dev.to/claudiodangelis</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F9187%2Fb5c5797e-c279-48d1-9621-96b8a890fc8a.jpg</url>
      <title>DEV Community: claudio d'angelis</title>
      <link>https://dev.to/claudiodangelis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/claudiodangelis"/>
    <language>en</language>
    <item>
      <title>qrcp: transfer files over wi-fi from your computer to your mobile device by scanning a QR code without leaving the terminal</title>
      <dc:creator>claudio d'angelis</dc:creator>
      <pubDate>Wed, 14 Oct 2020 12:24:30 +0000</pubDate>
      <link>https://dev.to/claudiodangelis/qrcp-transfer-files-over-wi-fi-from-your-computer-to-your-mobile-device-by-scanning-a-qr-code-without-leaving-the-terminal-12bd</link>
      <guid>https://dev.to/claudiodangelis/qrcp-transfer-files-over-wi-fi-from-your-computer-to-your-mobile-device-by-scanning-a-qr-code-without-leaving-the-terminal-12bd</guid>
      <description>&lt;p&gt;Hello everyone, here's a project that I have been working on in the last couple years. It's called &lt;a href="https://github.com/claudiodangelis/qrcp" rel="noopener noreferrer"&gt;qrcp&lt;/a&gt; and it's a command line tool to transfer files over Wi-Fi from your computer to a mobile device by scanning a QR code without leaving the terminal. &lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclaudiodangelis.com%2Fqrcp%2Fscreenshot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclaudiodangelis.com%2Fqrcp%2Fscreenshot.png" alt="Screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;qrcp&lt;/code&gt; binds a web server to the address of your Wi-Fi network interface on a random port and creates a handler for it. The default handler serves the content and exits the program when the transfer is complete. When used to receive files, &lt;code&gt;qrcp&lt;/code&gt; serves an upload page and handles the transfer.&lt;/p&gt;

&lt;p&gt;The tool prints a QR code that encodes the text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://{address}:{port}/{random_path}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most QR apps can detect URLs in decoded text and act accordingly (i.e. open the decoded URL with the default browser), so when the QR code is scanned the content will begin downloading by the mobile browser.&lt;/p&gt;

&lt;p&gt;Send files to mobile:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclaudiodangelis.com%2Fqrcp%2Fdemo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclaudiodangelis.com%2Fqrcp%2Fdemo.gif" alt="screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Receive files from mobile:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclaudiodangelis.com%2Fqrcp%2Fmobile-demo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclaudiodangelis.com%2Fqrcp%2Fmobile-demo.gif" alt="Screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Install the latest development version with Go
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Note: it requires go 1.8&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go get github.com/claudiodangelis/qrcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check the full GitHub's README for all the installation options: &lt;a href="https://github.com/claudiodangelis/qrcp#installation" rel="noopener noreferrer"&gt;installing qrcp&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Sending files
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Send a file
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp MyDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Send multiple files at once
&lt;/h2&gt;

&lt;p&gt;When sending multiple files at once, &lt;code&gt;qrcp&lt;/code&gt; creates a zip archive of the files or folders you want to transfer, and deletes the zip archive once the transfer is complete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Multiple files&lt;/span&gt;
qrcp MyDocument.pdf IMG0001.jpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# A whole folder&lt;/span&gt;
qrcp Documents/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Zip a file before transferring it
&lt;/h2&gt;

&lt;p&gt;You can choose to zip a file before transferring it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp &lt;span class="nt"&gt;--zip&lt;/span&gt; LongVideo.avi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Receive files
&lt;/h1&gt;

&lt;p&gt;When receiving files, &lt;code&gt;qrcp&lt;/code&gt; serves an "upload page" through which you can choose files from your mobile.&lt;/p&gt;

&lt;h2&gt;
  
  
  Receive files to the current directory
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qrcp receive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Receive files to a specific directory
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Note: the folder must exist&lt;/span&gt;
qrcp receive &lt;span class="nt"&gt;--output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Options
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;qrcp&lt;/code&gt; works without any prior configuration, however, you can choose to configure to use specific values. The &lt;code&gt;config&lt;/code&gt; command launches a wizard that lets you configure parameters like interface, port, fully-qualified domain name and keep alive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: if some network interfaces are not showing up, use the &lt;code&gt;--list-all-interfaces&lt;/code&gt; flag to suppress the interfaces' filter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp &lt;span class="nt"&gt;--list-all-interfaces&lt;/span&gt; config 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuration File
&lt;/h2&gt;

&lt;p&gt;The default configuration file is stored in $HOME/qrcp.json, however, you can specify the location of the config file by passing the &lt;code&gt;--config&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp &lt;span class="nt"&gt;--config&lt;/span&gt; /tmp/qrcp.json MyDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Port
&lt;/h2&gt;

&lt;p&gt;By default &lt;code&gt;qrcp&lt;/code&gt; listens on a random port. Pass the &lt;code&gt;--port&lt;/code&gt; (or &lt;code&gt;-p&lt;/code&gt;) flag to choose a specific one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp &lt;span class="nt"&gt;--port&lt;/span&gt; 8080 MyDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Network Interface
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;qrcp&lt;/code&gt; will try to automatically find the suitable network interface to use for the transfers. If more than one suitable interface is found, it asks you to choose one.&lt;/p&gt;

&lt;p&gt;If you want to use a specific interface, pass the &lt;code&gt;--interface&lt;/code&gt; (or &lt;code&gt;-i&lt;/code&gt;) flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The webserver will be visible by&lt;/span&gt;
&lt;span class="c"&gt;# all computers on the tun0's interface network&lt;/span&gt;
qrcp &lt;span class="nt"&gt;-i&lt;/span&gt; tun0 MyDocument.dpf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use a special interface name, &lt;code&gt;any&lt;/code&gt;, which binds the web server to &lt;code&gt;0.0.0.0&lt;/code&gt;, making the web server visible by everyone on any network, even from an external network. &lt;/p&gt;

&lt;p&gt;This is useful when you want to transfer files from your Amazon EC2, Digital Ocean Droplet, Google Cloud Platform Compute Instance or any other VPS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp &lt;span class="nt"&gt;-i&lt;/span&gt; any MyDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  URL
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;qrcp&lt;/code&gt; uses two patterns for the URLs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;send: &lt;code&gt;http://{ip address}:{port}/send/{random path}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;receive: &lt;code&gt;http://{ip address}:{port}/receive/{random path}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few options are available that override these patterns.&lt;/p&gt;

&lt;p&gt;Pass the &lt;code&gt;--path&lt;/code&gt; flag to use a specific path for URLs, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The resulting URL will be&lt;/span&gt;
&lt;span class="c"&gt;# http://{ip address}:{port}/send/x&lt;/span&gt;
qrcp &lt;span class="nt"&gt;--path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;x MyDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pass the &lt;code&gt;--fqdn&lt;/code&gt; (or &lt;code&gt;-d&lt;/code&gt;) to use a fully qualified domain name instead of the IP. This is useful in combination with &lt;code&gt;-i any&lt;/code&gt; you are using it from a remote location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The resulting URL will be&lt;/span&gt;
&lt;span class="c"&gt;# http://example.com:8080/send/xYz9&lt;/span&gt;
qrcp &lt;span class="nt"&gt;--fqdn&lt;/span&gt; example.com &lt;span class="nt"&gt;-i&lt;/span&gt; any &lt;span class="nt"&gt;-p&lt;/span&gt; 8080 MyRemoteDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  HTTPS
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;qrcp&lt;/strong&gt; supports secure file transfers with HTTPS. To enable secure transfers you need a TLS certificate and the associated key.&lt;/p&gt;

&lt;p&gt;You can choose the path to the TLS certificate and keys from the &lt;code&gt;qrcp config&lt;/code&gt; wizard, or, if you want, you can pass the &lt;code&gt;--tls-cert&lt;/code&gt; and &lt;code&gt;--tls-key&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qrcp &lt;span class="nt"&gt;--tls-cert&lt;/span&gt; /path/to/cert.pem &lt;span class="nt"&gt;--tls-key&lt;/span&gt; /path/to/cert.key MyDocument
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;--secure&lt;/code&gt; flag is available too, you can use it to override the default value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open in browser
&lt;/h2&gt;

&lt;p&gt;If you need a QR to be printed outside your terminal, you can pass the &lt;code&gt;--browser&lt;/code&gt; flag. With this flag, &lt;code&gt;qrcp&lt;/code&gt; will still print the QR code to the terminal, but it will also open a new window of your default browser to show the QR code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qrcp --browser MyDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Keep the server alive
&lt;/h2&gt;

&lt;p&gt;It can be useful to keep the server alive after transferring the file, for example, when you want to transfer the same file to multiple devices. You can use the &lt;code&gt;--keep-alive&lt;/code&gt; flag for that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The server will not shutdown automatically&lt;/span&gt;
&lt;span class="c"&gt;# after the first transfer&lt;/span&gt;
qrcp &lt;span class="nt"&gt;--keep-alive&lt;/span&gt; MyDocument.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Shell completion scripts
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;qrcp&lt;/code&gt; comes with a built-in &lt;code&gt;completion&lt;/code&gt; command that generates shell completion scripts. Check the &lt;a href="https://github.com/claudiodangelis/qrcp#shell-completion-scripts" rel="noopener noreferrer"&gt;shell completion&lt;/a&gt; section of the README for more information.&lt;/p&gt;

&lt;h1&gt;
  
  
  Future of the development
&lt;/h1&gt;

&lt;p&gt;I would like to add a few more features to this tool in the future, like file encryption, ability be used after a pipe, and more.&lt;/p&gt;

&lt;p&gt;If you give it a try, let me know how it goes! And am happy to answer your questions if you have.&lt;/p&gt;

&lt;p&gt;The project home is at &lt;a href="https://github.com/claudiodangelis/qrcp" rel="noopener noreferrer"&gt;github.com/claudiodangelis/qrcp&lt;/a&gt;, and there is a Telegram channel available if you want to receive news about the development: &lt;a href="https://t.me/qrcp_dev" rel="noopener noreferrer"&gt;qrcp Telegram channel&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br&gt;
Claudio&lt;/p&gt;

</description>
      <category>go</category>
      <category>cli</category>
      <category>tools</category>
      <category>qr</category>
    </item>
  </channel>
</rss>
