client examples - GamerDuck123/copyparty GitHub Wiki

interact with copyparty using non-browser clients

  • javascript: dump some state into a file (two separate examples)

    • await fetch('//127.0.0.1:3923/', {method:"PUT", body: JSON.stringify(foo)});
    • var xhr = new XMLHttpRequest(); xhr.open('POST', '//127.0.0.1:3923/msgs?raw'); xhr.send('foo');
  • curl/wget: upload some files (post=file, chunk=stdin)

    • post(){ curl -F f=@"$1" http://127.0.0.1:3923/?pw=wark;}
      post movie.mkv (gives HTML in return)
    • post(){ curl -F f=@"$1" 'http://127.0.0.1:3923/?want=url&pw=wark';}
      post movie.mkv (gives hotlink in return)
    • post(){ curl -H pw:wark -H rand:8 -T "$1" http://127.0.0.1:3923/;}
      post movie.mkv (randomized filename)
    • post(){ wget --header='pw: wark' --post-file="$1" -O- http://127.0.0.1:3923/?raw;}
      post movie.mkv
    • chunk(){ curl -H pw:wark -T- http://127.0.0.1:3923/;}
      chunk <movie.mkv
  • bash: when curl and wget is not available or too boring

    • (printf 'PUT /junk?pw=wark HTTP/1.1\r\n\r\n'; cat movie.mkv) | nc 127.0.0.1 3923
    • (printf 'PUT / HTTP/1.1\r\n\r\n'; cat movie.mkv) >/dev/tcp/127.0.0.1/3923
  • python: u2c.py is a command-line up2k client (webm)

  • FUSE: mount a copyparty server as a local filesystem

    • cross-platform python client available in ./bin/
    • able to mount nginx and iis directory listings too, not just copyparty
    • can be downloaded from copyparty: controlpanel -> connect -> partyfuse.py
    • rclone as client can give ~5x performance, see ./docs/rclone.md
  • sharex (screenshot utility): see ./contrib/sharex.sxcu

  • Custom Uploader (an Android app) as an alternative to copyparty's own PartyUP!

    • works if you set UploadURL to https://your.com/foo/?want=url&pw=hunter2 and FormDataName f
  • contextlet (web browser integration); see contrib contextlet

  • igloo irc: Method: post Host: https://you.com/up/?want=url&pw=hunter2 Multipart: yes File parameter: f

copyparty returns a truncated sha512sum of your PUT/POST as base64; you can generate the same checksum locally to verify uploads:

b512(){ printf "$((sha512sum||shasum -a512)|sed -E 's/ .*//;s/(..)/\\x\1/g')"|base64|tr '+/' '-_'|head -c44;}
b512 <movie.mkv

you can provide passwords using header PW: hunter2, cookie cppwd=hunter2, url-param ?pw=hunter2, or with basic-authentication (either as the username or password)

for basic-authentication, all of the following are accepted: password / whatever:password / password:whatever (the username is ignored)

NOTE: curl will not send the original filename if you use -T combined with url-params! Also, make sure to always leave a trailing slash in URLs unless you want to override the filename

folder sync

sync folders to/from copyparty

NOTE: full bidirectional sync, like what nextcloud and syncthing does, will never be supported! Only single-direction sync (server-to-client, or client-to-server) is possible with copyparty

the commandline uploader u2c.py with --dr is the best way to sync a folder to copyparty; verifies checksums and does files in parallel, and deletes unexpected files on the server after upload has finished which makes file-renames really cheap (it'll rename serverside and skip uploading)

alternatively there is rclone which allows for bidirectional sync and is way more flexible (stream files straight from sftp/s3/gcs to copyparty, ...), although there is no integrity check and it won't work with files over 100 MiB if copyparty is behind cloudflare

  • starting from rclone v1.63, rclone is faster than u2c.py on low-latency connections

mount as drive

a remote copyparty server as a local filesystem; go to the control-panel and click connect to see a list of commands to do that

alternatively, some alternatives roughly sorted by speed (unreproducible benchmark), best first:

most clients will fail to mount the root of a copyparty server unless there is a root volume (so you get the admin-panel instead of a browser when accessing it) -- in that case, mount a specific volume instead

if you have volumes that are accessible without a password, then some webdav clients (such as davfs2) require the global-option --dav-auth to access any password-protected areas