YACS

File sharing

YACS has two ways to share files.

Images

Images are uploaded to the server (POST /api/conversations/:conversation/send-file), stored under MEDIA_URL, and limited by MAX_IMAGE_KB (the client keeps images within 2560 px). Thumbnails and other sizes are produced on demand with Sharp by appending ?w=<width> to the media URL. Received images are cached in the browser (IndexedDB) so they load instantly and work offline.

Files, peer to peer

Other files are not uploaded. Instead the sender offers the file in the conversation and, once the recipient accepts, it streams directly between the two devices over a WebRTC data channel:

  1. The sender posts a file message with the name, MIME type and size, and registers a transfer offer with the server.
  2. The recipient accepts. The server issues a transfer ticket and verifies it when the sender's device is contacted, so only the intended recipient can pull the file.
  3. Data flows peer to peer using the @yacs/webshare protocol, with progress and transfer rate shown on both sides.
  4. The message status moves through ACCEPTED → PROGRESS → COMPLETED (or REJECTED / CANCELLED).

Because the file is never stored on the server, the sender's device must stay online until the transfer finishes. If the connection drops, the transfer resumes from the next missing chunk rather than starting over.

The sender can withdraw an offer at any time.