nice-room-70150
10/16/2025, 2:46 AMtall-airline-16756
10/16/2025, 2:46 AMtall-airline-16756
10/16/2025, 2:47 AMsendFile(_:for:) method to send a file stored on disk to participants in a room. This method needs a fileURL (which is the file's location) and a topic parameter to make sure the stream is routed to the right handlers.
If you want a bit more control, the sendFile(_:options:) method is a great option. It lets you send files with custom options, like specifying destination participants or adding metadata. When the file is sent successfully, it returns a ByteStreamInfo object with helpful details such as the file’s name, MIME type, total size, and a unique stream ID.
Here’s a simple example to get you started:
let fileURL = URL(filePath: "/path/to/file.pdf")
do {
let streamInfo = try await localParticipant.sendFile(fileURL, for: "documents")
print("File sent: \(streamInfo.name), Size: \(streamInfo.totalLength) bytes")
} catch {
print("Failed to send file: \(error.localizedDescription)")
}
To receive files, participants just need to register a byte stream handler for the topic using registerByteStreamHandler(for:) on the room instance. If you have any questions or need a hand with this, please don’t hesitate to ask—I’m here to help!
Sources: .github/workflows/ci.yaml | Sending files & bytes | LiveKit Docs | Realtime data | LiveKit Docs | Web and mobile frontends | LiveKit Docs