Expand description
File transfer: chunking, reassembly, hash verification, cache, save.
Cache layout: <data_dir>/files/cache/<file_id> // verified, complete <data_dir>/files/cache/<file_id>.part // in-progress reassembly
File-IDs are the SHA-256 hash of the wire bytes (plaintext for non-encrypted offers, ciphertext for encrypted offers — the encryption layer is a separate concern). Receivers verify each completed transfer’s bytes match the announced file_id before exposing the file to the caller.
Modules§
- encryption
- File encryption for room attachments.
Structs§
- Completed
File - What
accept_chunkreturns on the chunk that completes the transfer. - File
Manager - Outgoing
Plan - What
prepare_outgoinghands back: enough to drive a sequence of FileOffer + N FileChunk gossipsub messages.
Constants§
- CHUNK_
SIZE - Bytes per chunk on the wire. A
FileChunkis base64-encoded inside a JSON envelope, so the raw chunk must leave room for ~34% base64 expansion plus the envelope and still fit under gossipsub’s transmit limit. 40 KiB raw → ~55 KiB on the wire, comfortably under even the 64 KiB gossipsub default (and well under the 256 KiB ceiling huddle sets explicitly — seenetwork::start_network_with). - MAX_
FILE_ SIZE - Hard cap on a single offer for Phase 2. Larger files defer to a dedicated libp2p stream protocol (see plan.md Phase 3 notes).
Functions§
- guess_
mime - Best-effort MIME guess from a filename. Returns None for unknown extensions — receivers should not depend on this being present.