File Transfer Flow
ErikrafT Drop implements a sophisticated file transfer system that handles everything from small text messages to large multi-gigabyte files. The system uses WebRTC DataChannels for direct peer-to-peer transfers with WebSocket fallback when necessary.Transfer Lifecycle Overview
File Selection and Metadata
File Processing
MIME Type Detection
The system automatically detects and adds missing MIME types:Transfer Request Protocol
Request Message Structure
Request Handling
File Chunking System
FileChunker Class
TheFileChunker class breaks large files into manageable chunks:
Chunk Reading Process
Transfer Execution
Header Transmission
Progress Tracking
Partition Management
File Reception and Assembly
FileDigester Class
TheFileDigester class reassembles received chunks:
Message Types and Protocols
Transfer Control Messages
Request Message
Response Message
Header Message
Progress Message
Partition Messages
Completion Messages
Error Handling and Recovery
Transfer Cancellation
Connection Error Handling
Transfer Completion
Performance Optimizations
Memory Management
- Streaming: Files are processed in chunks to prevent memory overload
- Buffer Cleanup: Automatic cleanup of completed transfers
- iOS Limits: Special handling for iOS memory constraints
Network Efficiency
- Chunk Size: 64KB chunks balance memory usage and network efficiency
- Partition Tracking: 1MB partitions for progress reporting
- Binary Transfer: Direct binary data transfer via DataChannels
Progress Feedback
- Real-time Updates: Continuous progress reporting during transfer
- Partition Tracking: Granular progress for large files
- UI Integration: Seamless integration with user interface