u2c.py
Theu2c.py (upload to copyparty) client is a standalone Python script for uploading files and folders to a copyparty server using the up2k protocol.
Synopsis
Description
u2c.py is a robust upload client with features including:- Parallel uploads with configurable connections
- Multi-threaded file hashing
- Automatic resume of interrupted uploads
- File deduplication (only uploads missing chunks)
- File search mode
- Progress tracking with ETA
- Cross-platform (Python 2.6+ and 3.3+)
- Zero dependencies
Required Arguments
Server URL including destination folder.Examples:
http://192.168.1.100:3923/uploads/https://files.example.com/music/albums/
Files and/or folders to upload (multiple allowed).Note: Uses rsync-style syntax:
foouploads entire folder to URL/foo/foo/uploads contents of folder into URL/
Authentication Options
Password for copyparty authentication (sent in ‘PW’ header).Can be:
- Plain password:
-a hunter2 - Username:password if
--usernamesenabled:-a alice:hunter2 - Path to file containing password:
-a $~/.copyparty-pass
Password for HTTP basic authentication (usually not necessary).
Upload Behavior
Search mode - search for files instead of uploading.
Continue even if some local files are inaccessible.
If last-modified timestamps differ, push local timestamp to server.Requires: Write and delete permissions on server.
Overwrite existing files instead of auto-renaming.
Overwrite existing files only if server file is older.
Skip files matching regex pattern (repeatable).Example:
-x '.*/\.git/.*' -x '.*\.tmp$'Output Options
Verbose output (show detailed errors).
Print list of download links after all uploads finish.
Print download link after each upload finishes.
Write list of download links to file.Example:
-uf ~/upload-links.txtPrint upload/hash speeds for each file.
Performance Options
Number of parallel upload connections.Recommended:
1-2for low latency (same country)2-4for mobile clients2-6for high latency (cross-continental)
Number of CPU cores to use for hashing.Values:
0or1- Single-threaded hashing2-4- Recommended for most systems- Higher values show diminishing returns
Target POST size in MiB (tries to make each upload this big).
Maximum POST size in MiB (never exceed this).Note: Cloudflare maximum is 96 MiB.
Disable hashing while uploading (reduces parallelism).
Skip files if they exist at destination with similar timestamp.Note: Like turbo mode but even faster; skips files without hashing.
Use simple fallback approach (no parallelism, easier to debug).
Assume HTTP connections expire after this many seconds.
Delay in seconds before retrying failed handshake/upload.
Crash if handshakes fail due to server offline for this many seconds.
Folder Sync Options
Delete local files after successful upload.
Delete remote files that don’t exist locally (implies
--ow).Delete remote files during upload instead of after.Note: Reduces peak disk usage but will re-upload instead of detecting renames.
File-ID Calculator
When URL is-, u2c calculates and lists file warks (identifiers) instead of uploading.
Salt for creating warks (must match server config).
Verbose mode - print hash/offset of each chunk in each file.
Just print identifier + filepath (omit mtime/size).
TLS/SSL Options
Path to CA certificate or server certificate to verify.Example:
-te /path/to/cert.pemRequire correct hostname in certificate.
Disable TLS certificate verification (insecure).
Compatibility Options
Clear screen before starting upload.
Resolve hostname N times before upload.Note: Good for buggy networks but breaks TLS certificate validation.
No status panel (for slow consoles and macOS).
Examples
Basic upload
Upload with authentication
Fast parallel upload
Resume-friendly upload
Sync folder
Search for files
Upload with links
Calculate file IDs
Technical Details
Up2k Protocol
The up2k protocol used by u2c:- Hashing - Files are split into chunks (1-32 MiB) and SHA-512 hashed
- Handshake - Client sends chunk hashes to server
- Server Response - Server indicates which chunks are needed
- Upload - Only missing chunks are uploaded
- Assembly - Server assembles file from chunks
- Deduplication (same file uploaded once)
- Resume (interrupted uploads continue from where they left off)
- Bandwidth savings (only new data is transferred)
Chunk Size Selection
Chunk sizes are automatically selected based on file size:- Files < 256 MiB: 1 MiB chunks
- Files 256 MiB - 8 GiB: 2-8 MiB chunks
- Files > 8 GiB: Up to 32 MiB chunks
File Naming
By rsync convention:foldercreates URL/folder/ with folder contentsfolder/uploads contents directly into URL/
Exit Codes
0- Success1- Error (authentication failed, server offline, etc.)