Skip to main content

u2c.py

The u2c.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

string
required
Server URL including destination folder.Examples:
  • http://192.168.1.100:3923/uploads/
  • https://files.example.com/music/albums/
string
required
Files and/or folders to upload (multiple allowed).Note: Uses rsync-style syntax:
  • foo uploads entire folder to URL/foo/
  • foo/ uploads contents of folder into URL/

Authentication Options

string
Password for copyparty authentication (sent in ‘PW’ header).Can be:
  • Plain password: -a hunter2
  • Username:password if --usernames enabled: -a alice:hunter2
  • Path to file containing password: -a $~/.copyparty-pass
string
Password for HTTP basic authentication (usually not necessary).

Upload Behavior

boolean
Search mode - search for files instead of uploading.
boolean
Continue even if some local files are inaccessible.
boolean
If last-modified timestamps differ, push local timestamp to server.Requires: Write and delete permissions on server.
boolean
Overwrite existing files instead of auto-renaming.
boolean
Overwrite existing files only if server file is older.
string
Skip files matching regex pattern (repeatable).Example: -x '.*/\.git/.*' -x '.*\.tmp$'

Output Options

boolean
Verbose output (show detailed errors).
boolean
Print list of download links after all uploads finish.
boolean
Print download link after each upload finishes.
path
Write list of download links to file.Example: -uf ~/upload-links.txt
boolean
Print upload/hash speeds for each file.

Performance Options

integer
default:"2"
Number of parallel upload connections.Recommended:
  • 1-2 for low latency (same country)
  • 2-4 for mobile clients
  • 2-6 for high latency (cross-continental)
Note: Maximum is 6 in most browsers.
integer
default:"3"
Number of CPU cores to use for hashing.Values:
  • 0 or 1 - Single-threaded hashing
  • 2-4 - Recommended for most systems
  • Higher values show diminishing returns
integer
default:"64"
Target POST size in MiB (tries to make each upload this big).
integer
default:"96"
Maximum POST size in MiB (never exceed this).Note: Cloudflare maximum is 96 MiB.
boolean
Disable hashing while uploading (reduces parallelism).
boolean
Skip files if they exist at destination with similar timestamp.Note: Like turbo mode but even faster; skips files without hashing.
boolean
Use simple fallback approach (no parallelism, easier to debug).
float
default:"57"
Assume HTTP connections expire after this many seconds.
float
default:"5"
Delay in seconds before retrying failed handshake/upload.
float
default:"186"
Crash if handshakes fail due to server offline for this many seconds.

Folder Sync Options

boolean
Delete local files after successful upload.
boolean
Delete remote files that don’t exist locally (implies --ow).
boolean
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.
string
default:"hunter2"
Salt for creating warks (must match server config).
boolean
Verbose mode - print hash/offset of each chunk in each file.
boolean
Just print identifier + filepath (omit mtime/size).

TLS/SSL Options

path
Path to CA certificate or server certificate to verify.Example: -te /path/to/cert.pem
boolean
Require correct hostname in certificate.
boolean
Disable TLS certificate verification (insecure).

Compatibility Options

boolean
Clear screen before starting upload.
integer
default:"0"
Resolve hostname N times before upload.Note: Good for buggy networks but breaks TLS certificate validation.
boolean
No status panel (for slow consoles and macOS).

Examples

Basic upload

Upload contents of photos folder to server root.

Upload with authentication

Upload single file with password.

Fast parallel upload

Use 4 parallel connections and 4 CPU cores for hashing.

Resume-friendly upload

Upload with automatic resume if interrupted.

Sync folder

Sync folder, deleting remote files not present locally.

Search for files

Search for matching files on server.
Upload PDFs and save download links to file.

Calculate file IDs

Generate warks for files without uploading.

Technical Details

Up2k Protocol

The up2k protocol used by u2c:
  1. Hashing - Files are split into chunks (1-32 MiB) and SHA-512 hashed
  2. Handshake - Client sends chunk hashes to server
  3. Server Response - Server indicates which chunks are needed
  4. Upload - Only missing chunks are uploaded
  5. Assembly - Server assembles file from chunks
This enables:
  • 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
This ensures optimal deduplication and server performance.

File Naming

By rsync convention:
  • folder creates URL/folder/ with folder contents
  • folder/ uploads contents directly into URL/

Exit Codes

  • 0 - Success
  • 1 - Error (authentication failed, server offline, etc.)

See Also