nice-room-70150
11/21/2025, 10:39 PMtall-airline-16756
11/21/2025, 10:39 PMtall-airline-16756
11/21/2025, 10:40 PMsendFile method and register a byte-stream handler to receive files.
1) Sending (from a browser or Node):
// file from an <input> or a Blob
const file = fileInput.files?.[0];
if (file) {
const info = await room.localParticipant.sendFile(file, {
mimeType: file.type,
topic: 'my-topic',
onProgress: (p) => console.log('progress', Math.round(p * 100) + '%'),
});
console.log('sent file stream id', info.id);
}
You can also pass a file path or Blob. Options:
• `topic`: string to target receivers
• `onProgress(progress: number)`: 0–1 progress callback
• `mimeType`: override MIME type
2) Receiving:
room.registerByteStreamHandler('my-topic', async (stream) => {
// stream contains metadata and a readable stream of bytes
// consume and save/display the file as needed
});
If you want, tell me:
• whether you're in browser or Node
• example file type/size
and I’ll provide a concrete receive-handler example for that environment.
Sources: Sending files & bytes | LiveKit docsnice-room-70150
11/21/2025, 10:54 PMtall-airline-16756
11/21/2025, 10:54 PMsendFile(). Yes — @livekit/rtc-node provides sendFile() on LocalParticipant (same usage as the browser SDK).
Example (Node):
const info = await room.localParticipant.sendFile('path/to/file.jpg', {
topic: 'my-topic',
onProgress: (p) => console.log('progress', Math.round(p * 100) + '%'),
});
console.log('sent file stream id', info.id);
To receive files, use:
room.registerByteStreamHandler('my-topic', async (stream) => {
// consume stream bytes and save/display the file
});
Would you like a full Node receive-handler example that writes the incoming stream to disk and shows progress?
Sources: Sending files & bytes | LiveKit docsnice-room-70150
11/21/2025, 10:56 PMtall-airline-16756
11/21/2025, 10:57 PMsendFile() method was added in @livekit/rtc-node starting with version 0.8.0.
Sources: Sending files & bytes | LiveKit docsnice-room-70150
11/21/2025, 11:10 PMtall-airline-16756
11/21/2025, 11:10 PMsendFile() isn't available in your @livekit/rtc-node@0.11.1 setup and you need to use publishData() instead. I can help with a concise pattern for sending files with publishData() and receiving them with registerDataReceivedHandler.
Do you want a Node.js example that:
• chunks a file, publishes chunks with metadata (filename, chunk index, total, mime), and shows progress, and
• a receive handler that reassembles the chunks and writes the file to disk?
If yes, tell me whether you're using plain Node (no bundler) and the file sizes you expect (so I can recommend chunk size).