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. Picked to fit comfortably under gossipsub’s per-message budget even after base64 expansion (64 KiB raw → ~88 KiB base64).
- 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.