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

python u2c.py [OPTIONS] URL FILES...

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

url
string
required
Server URL including destination folder.Examples:
  • http://192.168.1.100:3923/uploads/
  • https://files.example.com/music/albums/
files
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

-a
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
--ba
string
Password for HTTP basic authentication (usually not necessary).

Upload Behavior

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

Output Options

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

Performance Options

-j
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.
-J
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
--sz
integer
default:"64"
Target POST size in MiB (tries to make each upload this big).
--szm
integer
default:"96"
Maximum POST size in MiB (never exceed this).Note: Cloudflare maximum is 96 MiB.
-nh
boolean
Disable hashing while uploading (reduces parallelism).
-z
boolean
Skip files if they exist at destination with similar timestamp.Note: Like turbo mode but even faster; skips files without hashing.
--safe
boolean
Use simple fallback approach (no parallelism, easier to debug).
--cxp
float
default:"57"
Assume HTTP connections expire after this many seconds.
--cd
float
default:"5"
Delay in seconds before retrying failed handshake/upload.
--t-hs
float
default:"186"
Crash if handshakes fail due to server offline for this many seconds.

Folder Sync Options

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

TLS/SSL Options

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

Compatibility Options

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

Examples

Basic upload

python u2c.py http://192.168.1.100:3923/ ~/photos/
Upload contents of photos folder to server root.

Upload with authentication

python u2c.py -a hunter2 http://server:3923/uploads/ file.zip
Upload single file with password.

Fast parallel upload

python u2c.py -j 4 -J 4 http://server:3923/docs/ ~/Documents/
Use 4 parallel connections and 4 CPU cores for hashing.

Resume-friendly upload

python u2c.py -j 2 --safe http://server:3923/backup/ /data/
Upload with automatic resume if interrupted.

Sync folder

python u2c.py --dr -z http://server:3923/mirror/ ~/sync/
Sync folder, deleting remote files not present locally.

Search for files

python u2c.py -s http://server:3923/ "vacation-2024*.jpg"
Search for matching files on server.
python u2c.py -ud -uf links.txt http://server:3923/share/ *.pdf
Upload PDFs and save download links to file.

Calculate file IDs

python u2c.py - ~/files/ --wsalt mysecret
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

Build docs developers (and LLMs) love