How I Built QuickShare-QR: Share Files from Terminal to Phone via Instant ASCII QR Codes
Every developer encounters this awkward friction almost every week: You have an APK file, a configuration snippet, an invoice PDF, or a test video on your development machine, and you need to send it to your phone right
Every developer encounters this awkward friction almost every week:
You have an APK file, a configuration snippet, an invoice PDF, or a test video on your development machine, and you need to send it to your phone right now.
What do most of us do?
- Email the file to ourselves.
- Send it over a Telegram "Saved Messages" chat.
- Upload it to Google Drive or Dropbox and wait for cloud syncing.
All these methods upload your local files to external third-party cloud servers just to travel 30 centimeters across your desk over the same local Wi-Fi router.
To eliminate this friction, I built QuickShare-QR β a zero-setup Node.js CLI tool that spins up a secure, ephemeral local HTTP server and prints a scannable ASCII QR code directly into your terminal.
How it Works
[Developer Machine] [Smartphone / Tablet]
β β
$ npx quickshare-qr test.pdf β
β β
βββ 1. Discovers Local LAN IP (192.168.1.X) β
βββ 2. Spins up Ephemeral HTTP Server on random port β
βββ 3. Renders ANSI QR Code directly in Terminal β
β β
βββββββββββ [Scan with Camera] ββββββββββ€
β
Direct LAN Streaming Download
(No app installation needed!)
1. Zero Cloud, Zero External Servers
The transfer happens 100% peer-to-peer over your local Wi-Fi / LAN network. Files never leave your local router. Speed is limited only by your local Wi-Fi bandwidth (often 30β80 MB/s).
2. Native Camera Scanning (No Client App Required)
Because QuickShare-QR serves standard HTTP with proper Content-Disposition headers, the receiver does not need to install any app.
Just point the phone's default camera at the terminal QR code, tap the notification, and the browser immediately begins downloading.
3. Direct Streaming with Ephemeral Auto-Shutdown
The CLI streams files chunk-by-chunk using Node.js read streams:
import http from 'node:http';
import fs from 'node:fs';
const server = http.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'application/octet-stream',
'Content-Disposition': `attachment; filename="${fileName}"`,
'Content-Length': fileStat.size,
});
const fileStream = fs.createReadStream(filePath);
fileStream.pipe(res);
fileStream.on('end', () => {
console.log('Transfer complete! Shutting down server...');
setTimeout(() => server.close(), 1000);
});
});
As soon as the file finishes downloading, the server gracefully shuts down and releases the port.
Security & Path Traversal Protection
Allowing devices on the local network to fetch files requires strict security boundaries:
-
Path Confinement: Prevents directory traversal attacks (
../) by strictly binding the HTTP route to the single selected target file. - Dynamic Ephemeral Ports: Binds to arbitrary available ports to prevent conflict and sniffing.
- Optional Single-Use Tokens: Guarantees that only the device that scanned the terminal QR code can initiate the download.
Quick Start in 5 Seconds
You don't need to install anything permanently:
# Share any file instantly over LAN
npx quickshare-qr ./my-presentation.pdf
# Share an archive or photo
npx quickshare-qr ./assets.zip
Point your phone's camera at your terminal screen, and the transfer starts immediately!
Source Code & Community
QuickShare-QR is open source under the MIT license.
π GitHub Repository: github.com/mahdyarmonfared/quickshare-qr
I'd love your feedback:
- Would you like support for receiving files (uploading from phone back to terminal)?
- What other local sharing protocols or encryption layers would make this even better?
Feel free to open an issue or drop a star β on GitHub!
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.