Dev.to WebDev 🛠 Dev 👁 0 📖 2 min read

Sending Files Phone to PC Without an App: What WebRTC Can and Cannot Do

Every time I want to move a photo from my phone to my laptop, I go through the same ritual: find a cable, plug it in, wonder why the laptop does not see the phone, then email the photo to myself. It works, but it feels l

Every time I want to move a photo from my phone to my laptop, I go through the same ritual: find a cable, plug it in, wonder why the laptop does not see the phone, then email the photo to myself. It works, but it feels like a workaround for a problem browser APIs solved years ago. Here is what I learned while looking into browser-based transfer tools, and why DropAny is a decent example of the pattern.

The core idea: a DataChannel instead of a server

WebRTC is usually associated with video calls, but RTCDataChannel is just a bidirectional pipe between two peers. For file transfer you need three things:

  1. Signaling. Two browsers that have never met need to exchange SDP offers and ICE candidates. That requires a tiny server, but the server only relays text — the files never touch it.
  2. A pairing step. Typing a long room ID on a phone keyboard is miserable, so most tools generate a short one-time code. DropAny uses a 6-digit code or a QR scan, which is single-use and expires after 10 minutes.
  3. Chunked sending. You cannot push a 500 MB file into a DataChannel in one call. You slice the file with file.slice() and send chunks, watching bufferedAmount so the channel does not back up.

What works surprisingly well

Once the channel is open, transfers are fast on a local network because traffic goes device to device instead of across the internet twice. Because the transport is DTLS-encrypted, the sender and receiver are the only parties that see the bytes — which is a real argument when you are moving scans of a passport or a medical letter.

In my case the win was cross-platform. Sending from an iPhone to a Windows machine is exactly the scenario where the usual ecosystem tools fail loudly, and a WebRTC page does not care about the operating system on either side.

Where it still hurts

  • No resume. A DataChannel does not survive a network switch. If Wi-Fi drops halfway through a large video, most of these tools restart from zero.
  • Tabs die. A backgrounded mobile tab can be frozen by the OS. Keep the screen awake and the tab in front.
  • Not every network allows it. Symmetric NATs and some corporate firewalls require a TURN relay; if a tool only ships STUN servers, peers on the same network are fine but anything harder may fail.

The honest summary

If you need reliable, resumable bulk transfer of huge archives, a sync client is still the right tool. If you need to move a handful of files between two devices, once, without installing anything, the browser route is now genuinely good. DropAny leans into that narrow but very common case: no app, no account, no upload to a server, and the files simply go from one device to the other.

For a web developer, the more interesting takeaway is how little code this takes now. A pairing UI, a signaling socket, and a chunked send loop on top of RTCDataChannel is a weekend project — and unlike most weekend projects, people actually use it.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.