Giter VIP home page Giter VIP logo

qrcp's Introduction

Logo

$ qrcp

Transfer files over Wi-Fi from your computer to a mobile device by scanning a QR code without leaving the terminal.

Go Report Card

You can support development by donating with Buy Me A Coffee.

Join the Telegram channel qrcp_dev or the @qrcp_dev Twitter account for news about the development.

How does it work?

Screenshot

qrcp 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, qrcp serves an upload page and handles the transfer.

The tool prints a QR code that encodes the text:

http://{address}:{port}/{random_path}

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.

Send files to mobile:

screenshot

Receive files from mobile:

Screenshot

Tutorials

Installation

Install the latest development version with Go

Note: it requires go 1.18

go install github.com/claudiodangelis/qrcp@latest

Linux

Download the latest Linux .tar.gz archive from the Releases page, extract it, move the binary to the proper directory, then set execution permissions.

# Extract the archive
tar xf qrcp_0.5.0_linux_x86_64.tar.gz
# Copy the binary
sudo mv qrcp /usr/local/bin
# Set execution permissions
sudo chmod +x /usr/local/bin/qrcp

Raspberry Pi

The following ARM releases are available in the Releases page:

  • armv7
  • arm64

Using a package manager

ArchLinux

Packages available on AUR:

Deb packages (Ubuntu, Debian, etc)

Download the latest .deb package from the Releases page, then run dpkg:

sudo dpkg -i qrcp_0.5.0_linux_x86_64.deb
# Confirm it's working:
qrcp version

RPM packages (CentOS, Fedora, etc)

Download the latest .rpm package from the Releases page, then run rpm:

sudo rpm -i qrcp_0.5.0_linux_x86_64.rpm
# Confirm it's working:
qrcp --help

Windows

Download the latest Windows .tar.gz archive from the Releases page and extract the EXE file.

Scoop

If you use Scoop for package management on Windows, you can install qrcp with the following one-liner:

scoop install qrcp

Chocolatey

If you use Chocolatey for package management on Windows, you can install qrcp with the following one-liner:

choco install qrcp

MacOS

Download the latest macOS .tar.gz archive from the Releases page, extract it, move the binary to the proper directory, then set execution permissions.

# Extract the archive
tar xf qrcp_0.5.0_macOS_x86_64.tar.gz
# Copy the binary
sudo mv qrcp /usr/local/bin
# Set execution permissions
sudo chmod +x /usr/local/bin/qrcp
# Confirm it's working:
qrcp --help

Homebrew

If you use Homebrew for package management on macOS, you can install qrcp with the following one-liner:

brew install qrcp

Usage

Send files

Send a file

qrcp MyDocument.pdf

Send multiple files at once

When sending multiple files at once, qrcp creates a zip archive of the files or folders you want to transfer, and deletes the zip archive once the transfer is complete.

# Multiple files
qrcp MyDocument.pdf IMG0001.jpg
# A whole folder
qrcp Documents/

Zip a file before transferring it

You can choose to zip a file before transferring it.

qrcp --zip LongVideo.avi

Receive files

When receiving files, qrcp serves an "upload page" through which you can choose files from your mobile.

Receive files to the current directory

qrcp receive

Receive files to a specific directory

# Note: the folder must exist
qrcp receive --output=/tmp/dir

Configuration

qrcp works without any prior configuration, however, you can choose to configure to use specific values.

To configure qrcp you can create a configuration file inside $XDG_CONFIG_HOME/qrcp.

Note: On Linux, the $XDG_CONFIG_HOME is .config under user home directory. So, for example, on Linux the configuration file will be $HOME/.config/qrcp/config.yml. On MacOS, it defaults to `$HOME/Library/Application Support/qrcp/config.yml``

Note: Starting from version 0.10.0, qrcp uses a YAML configuration file instead of the old JSON one. You can automatically migrate the legacy JSON format to the new YAML format by running qrcp config migrate.

Key Type Notes
interface String This value is automatically discovered during the first launch of qrcp, you can set it to override the default. You can use the any interface to bind the web server to 0.0.0.0.
bind String This value is used by qrcp to bind the web server to. Note: if this value is set, the interface parameter is ignored.
port Integer When this value is not set, qrcp will pick a random port at any launch.
path String When this value is not set, qrcp will add a random string at the end of URL.
output String Default directory to receive files to. If empty, the current working directory is used.
fqdn String When this value is set, qrcp will use it to replace the IP address in the generated URL.
keepAlive Bool Controls whether qrcp should quit after transferring the file. Defaults to false.
secure Bool Controls whether qrcp should use HTTPS instead of HTTP. Defaults to false
tls-cert String Path to the TLS certificate. It's only used when secure: true.
tls-key String Path to the TLS key. It's only used when secure: true.
reversed Bool Reverse QR code (black text on white background)?" true`.

All the configuration parameters can be controlled via environment variables prefixed with QRCP_, for example:

  • $QRCP_INTERFACE
  • $QRCP_PORT
  • $QRCP_KEEPALIVE
  • etc

Config Wizard

The config command launches a wizard that lets you configure parameters like interface, port, fully-qualified domain name and keep alive.

qrcp config

Note: if some network interfaces are not showing up, use the --list-all-interfaces flag to suppress the interfaces' filter.

qrcp --list-all-interfaces config

Configuration File

The default configuration file is stored in $XDG_CONFIG_HOME/qrcp/config.yml, however, you can specify the location of the config file by passing the --config flag:

qrcp --config /tmp/qrcp.yml MyDocument.pdf

Port

By default qrcp listens on a random port. Set the QRCP_PORT environment variable or pass the --port (or -p) flag to choose a specific one:

export QRCP_PORT=8080
qrcp MyDocument

Or:

qrcp --port 8080 MyDocument.pdf

Network Interface

qrcp 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.

If you want to use a specific interface, pass the --interface (or -i) flag:

# The webserver will be visible by
# all computers on the tun0's interface network
qrcp -i tun0 MyDocument.dpf

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

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.

qrcp -i any MyDocument.pdf

Bind

Alternatively to choosing the interface, you can directly specify the address you want qrcp to bind the webserver to.

qrcp --bind 10.20.30.40 MyDocument.pdf

URL

qrcp uses two patterns for the URLs:

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

A few options are available that override these patterns.

Pass the --path flag to use a specific path for URLs, for example:

# The resulting URL will be
# http://{ip address}:{port}/send/x
qrcp --path=x MyDocument.pdf

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

# The resulting URL will be
# http://example.com:8080/send/xYz9
qrcp --fqdn example.com -i any -p 8080 MyRemoteDocument.pdf

HTTPS

qrcp supports secure file transfers with HTTPS. To enable secure transfers you need a TLS certificate and the associated key.

You can choose the path to the TLS certificate and keys from the qrcp config wizard, or, if you want, you can pass the --tls-cert and --tls-key:

qrcp --tls-cert /path/to/cert.pem --tls-key /path/to/cert.key MyDocument

A --secure flag is available too, you can use it to override the default value.

Default output directory

Open in browser

If you need a QR to be printed outside your terminal, you can pass the --browser flag. With this flag, qrcp 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.

qrcp --browser MyDocument.pdf

Keep the server alive

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 --keep-alive flag for that:

# The server will not shutdown automatically
# after the first transfer
qrcp --keep-alive MyDocument.pdf

Shell completion scripts

qrcp comes with a built-in completion command that generates shell completion scripts.

Bash:

$ source <(qrcp completion bash)

To load completions for each session, execute once:

Linux:

$ qrcp completion bash > /etc/bash_completion.d/qrcp

Note: if you don't want to install completion scripts system-wide, refer to Bash Completion FAQ.

MacOS:

$ qrcp completion bash > /usr/local/etc/bash_completion.d/qrcp

Zsh:

If shell completion is not already enabled in your environment you will need to enable it. You can execute the following once:

$ echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions for each session, execute once:

$ qrcp completion zsh > "${fpath[1]}/_qrcp"

You will need to start a new shell for this setup to take effect.

Fish:

$ qrcp completion fish | source

To load completions for each session, execute once:

$ qrcp completion fish > ~/.config/fish/completions/qrcp.fish

Authors

qrcp, originally called qr-filetransfer, started from an idea of Claudio d'Angelis (@claudiodangelis on Telegram), the current maintainer, and it's developed by the community.

Join us!

Credits

Logo is provided by @arasatasaygin as part of the openlogos initiative, a collection of free logos for open source projects.

Check out the rules to claim one: rules of openlogos.

Releases are handled with goreleaser.

Clones and Similar Projects

  • qr-fileshare - A similar idea executed in NodeJS with a React interface.
  • instant-file-transfer (Uncredited) - Node.js project similar to this
  • qr-filetransfer - Python clone of this project
  • qr-filetransfer - Another Node.js clone of this project
  • qr-transfer-node - Another Node.js clone of this project
  • QRDELIVER - Node.js project similar to this
  • qrfile - Transfer files by scanning a QR code
  • quick-transfer - Node.js clone of this project
  • share-file-qr - Python re-implementation of this project
  • share-files (Uncredited) - Yet another Node.js clone of this project
  • ezshare - Another Node.js two way file sharing tool supporting folders and multiple files
  • local_file_share - "share local file to other people, OR smartphone download files which is in pc"
  • qrcp - a desktop app clone of qrcp, writing with C# and .NET Core, work for Windows.
  • swift_file - Rust project inspired by qrcp.

License

MIT. See LICENSE.

qrcp's People

Contributors

0xflotus avatar 0xmohit avatar anoop-b avatar arkanosis avatar brualan avatar camgraff avatar cehnegaitne avatar claudiodangelis avatar codeman99 avatar darienflamont avatar dependabot[bot] avatar dpeukert avatar fgaz avatar fritzrehde avatar gs0510 avatar hellozee avatar i-dont-remember avatar iainsgillis avatar imgbotapp avatar joekyo avatar katakonst avatar mateoradman avatar mattn avatar mb-14 avatar mifi avatar mrheer avatar natescarlet avatar rafa-acioly avatar tssva avatar vladimyr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qrcp's Issues

Use ipv4 addresses instead of ipv6

On Windows, the program uses ipv6 on most/all network interfaces. This seems to cause problems with both qr code readers as well as connecting to the computer

Generated code does not scan reliably with Source Code Pro font

I'm using iTerm2, with Source Code Pro as my monospaced font. The QR code doesn't scan reliably, as there's some gaps where the pattern should be continuous. Is there a Unicode char that is guaranteed to take up the entire height/width that could be used?

screen shot 2018-03-22 at 4 34 15 pm

zip.AddFile undefined when running "go get github.com/claudiodangelis/qr-filetransfer"

I'm opening this issue because:

  • I have found a bug
  • I want to request a feature
  • I have a question
  • Other

I am trying to install the binary with go get github.com/claudiodangelis/qr-filetransfer, and getting the following error:

/Users/issmirnov/go/github.com/claudiodangelis/qr-filetransfer/content.go:54:7: zip.AddFile undefined (type *archivex.ZipFile has no field or method AddFile)

It is coming from here.

I have reproduced this on two systems: ubuntu and OSX.

OSX:

$ go version
go version go1.10.3 darwin/amd64

$ echo $GOPATH
/Users/issmirnov/go

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.2
BuildVersion:	17C88

Ubuntu:

$ go version
go version go1.9.4 linux/amd64

$ echo $GOPATH
/Users/issmirnov/go

$ uname -r
Linux mysecrethostname 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ $ cat /etc/lsb-release                     
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LT

QR code doesn't properly render on Windows

I'm opening this issue because:

  • I have found a bug
  • I want to request a feature
  • I have a question
  • Other

the qrcode is too big!!!
When I zoom the cmd window, the QR code disappears.

1

image

  • My Go version is: (paste the output of go version and remember that qrcp requires at least version 1.8 of Go)
  • My GOPATH is set to: (paste the output of echo $GOPATH)

Automatically choose the network interface if there is only one candidate

The getAddress() function chooses the network interface to use. The current workflow is:

  1. Get all network interfaces
  2. Filter out those that won't work:
    • virtual eth, loopback, docker, bridge, etc
    • interfaces that are down
  3. Ask the user which one they want to use
  4. Set that interface as "default" and never ask again

However, after filtering out invalid interfaces, there is a high chance that the remaining interfaces will be just one -- the wifi interface -- as we assume that the average user has just one wifi card on their computer.

After filtering, if the length of filteredInterfaces is 1, the tool should automatically choose that interface, without asking the user.

Unable to install using instructions

By following the README I don't get an executable in my PATH. Tips?

$ apt install golang-go

$ go get -v github.com/claudiodangelis/qr-filetransfer

$ which qr-filetransfer

$  qr-filetransfer
qr-filetransfer: Could not find command

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu Bionic Beaver (development branch)"

$ go version
go version go1.10 linux/amd64

Server could not start on latest mac OS with latest go runtime

qr-filetransfer -debug video.mp4
2018/03/23 09:16:29 [Current user is xx]
Choose the network interface to use (type the number):
[0] lo0
[1] gif0
[2] stf0
[3] XHC20
[4] en0
[5] p2p0
[6] awdl0
[7] en1
[8] en2
[9] bridge0
[10] utun0
[11] utun1
[12] utun2
[13] utun3
4
Scan the following QR to start the download.
Make sure that your smartphone is connected to the same WiFi network as this computer.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▄▄▄ █ ▄  █▄▄▄▄█▄▀▄█ ▄▄▄▄▄ █
█ █   █ █▄ ██▄▀▄▄ ▄  ██ █   █ █
█ █▄▄▄█ █ ███  █ █▀  ▀█ █▄▄▄█ █
█▄▄▄▄▄▄▄█ ▀ █ ▀ █ ▀ ▀ █▄▄▄▄▄▄▄█
██▀▄▀▀█▄▄▄▀█▀█  ██▄█▀█   ▄█ ▄ █
█▄█▀██ ▄▀█▀ ▄  █ █ ▀▄ ▀▄ ▄▀▀▄▀█
██▀█  ▄▄█▄ ▄ ██▀█▄ ▄ ██▀█▄ ▄ ██
█▀▀ ▀  ▄▀██▄▄▄▄█▀██▄▄ ▄█▀██▄ ▄█
█▄██▄▄ ▄▀▀▀█ ▀▀█ ▀█ ▀▀█▄   █  █
█▀  ▄ ▀▄▄▄▄█▄▄▄█ ▄▄▄▀▄  ▄▄ ▄███
█▄█▄▄▄█▄▄ ▄█▀▄▄█ ▀▀██ ▄▄▄  ▀▄ █
█ ▄▄▄▄▄ █▄ █   █▀  ▄  █▄█ ███▀█
█ █   █ ██▀█ ▀▀▄▀██  ▄▄ ▄▄▄▄█▄█
█ █▄▄▄█ █▄█ ▀▀▄▀▀▀▄▀▀█ ▀█▀▀█▀▀█
█▄▄▄▄▄▄▄██▄▄█▄▄▄█▄▄▄██▄▄█▄▄▄█▄█
2018/03/23 09:16:30 listen tcp: address fe80::8c7:a5cf:6a55:90ed:57160: too many colons in address

qr-filetransfer/main.go:93: srv.Shutdown undefined

I'm opening this issue because:

  • I have found a bug
  • I want to request a feature
  • I have a question
  • Other

it display this
gotest go get github.com/claudiodangelis/qr-filetransfer
github.com/claudiodangelis/qr-filetransfer
src/github.com/claudiodangelis/qr-filetransfer/main.go:93: srv.Shutdown undefined (type *http.Server has no field or method Shutdown)
src/github.com/claudiodangelis/qr-filetransfer/main.go:163: undefined: http.ErrServerClosed

when i go get it.

I do not know what happen,beacuse i know few for golang.

  • My Go version is: (version go1.7beta1 darwin/amd64)
  • My GOPATH is set to: (/Users/sunxiaokai/gotest)

Support ip4 when network device has ip6 as well

When running it, I get the below (with my ip6 address redacted)

2018/03/22 14:41:25 listen tcp: address <ip6 address>:50877: too many colons in address

I assume this is because it has grabbed the inet6 settings. However, using the same device I also have inet and it would likely work just fine using those.

feature request: add support for HTTPS

Downloading files over HTTP is never a good idea, even if you're just downloading from your own laptop. Fortunately Go makes super easy having a HTTPS server, feel free to steal the code here and here ^_^

Add support for sending text to phone

I'm opening this issue because:

  • I have found a bug
  • I want to request a feature
  • I have a question
  • Other

I think it would be cool to be able to send text from my pc to my phone directly. QRCP wouldn't even need to start the server, just render the qr code with the text.

Sorry.It's my fault.

I'm opening this issue because:

  • I have found a bug

  • I want to request a feature

  • I have a question

  • Other

  • My Go version is: (paste the output of go version and remember that qr-filetransfer requires at least version 1.8 of Go)

  • My GOPATH is set to: (paste the output of echo $GOPATH)

Server closes before download is completed

I was trying to send some audios to my phone, on the first file, I got the behavior depicted in the image on the first try and on the second one the download finished successfully, when transferring the second audio I think I tried 3 times and got this behavior the 3 times, I don't know if this would be specific to my phone or something, but maybe an option to keep the server running or adding a delay to it could solve this(assuming I didn't do anything wrong).

Files were around 30mb of mp3. Using Ubuntu 16.04.

Implement as drag-and-drop desktop app

Not all users are tech-savvy enough to use command-line tools, what about bringing the concept of "scan & transfer" to regular desktop apps?

There might be a couple of usages, for example:

  1. User launches the app, the main window is just a panel through which they can drag and drop the file(s) onto, or click a good old "Select file(s)" button
  2. User drags the file(s) onto the app icon itself (I think many mac apps work this way)

Afterwards, a QR code is displayed and users can scan & download.

What do you think? Please share your ideas on this, thank you!

automatic network interface detection

On Linux under /sys/class/net/<iface>/ there exists a directory called wireless if this interface is wifi capable.

Maybe you can reduce the number of available network interfaces to only those who are wireless, or in case of only one such interface, entirely skip the selection.
Only if run on linux of course.

Add an option to upload file

If no filename is provided, generate a link to upload form instead, so it is possible to upload a file from phone to the server.

Server still disconnects when transferring APK file on Android phone

I'm opening this issue because:

  • I have found a bug

  • I want to request a feature

  • I have a question

  • Other

  • My Go version is: go version go1.10.3 darwin/amd64

  • My GOPATH is set to: ~/go

I'm using the latest version of the tool (I ran go get … last night) and saw that #13 was supposed to be resolved.

But I continue to experience problems.

I'm trying to transfer an APK file to an Android device. When I scan the code with, say, Zxing, Google Assistant/Lens, or even Twitter, I get redirected to a browser, which gives me a popup warning that the file is potentially harmful (since it's an application not downloaded from Google Play store). The connection drops at that point. Sometimes a partial download occurs. (I'm guessing the browser application downloads the file in the background, while the user answers the prompt.)

Is there anything I can do, to help you diagnose this issue?

Add sending a string

I'm opening this issue because:

  • I have found a bug

  • I want to request a feature

  • I have a question

  • Other

  • My Go version is: go1.13.7 linux/amd64

  • My GOPATH is set to: /home/gavinok/go:/home/gavinok/Programming/go

windows installation issue

I'm opening this issue because:

  • I have found a bug
  • I want to request a feature
  • [Y] I have a question
  • Other

I'm really sorry to submit this issue for asking easy question. But I really have difficult to install QRCP on Windows.
I have downloaded Go Lang and use "go get ~/qrcp" cmd. But i can't find Chmod Command on Windows.
And there's no ".exe" file in the released package.
Can you add a windows version installation guide?
Really thanks for that.

Support transfer a link

I would like qr-filetransfer also support

qr-filetransfer https://www.google.com

That's easy but that I can transfer anything via the same tool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.