A simple standalone webserver which you can upload and download files to/from using just a web browser. By running just one instance of the uploadserver, you can transfer files between devices on your local network without installing anything on them.
Compiling the source code for your machine by following the steps below will optimize the server to use your machine to its full capability. However, if you are lazy or in a hurry, you can download pre-built binaries on the Releases page.
-
Install rust toolchain manager:
# Arch Linux sudo pacman -S rustup # Other Linux Distributions curl https://sh.rustup.rs -sSf | shOn Windows: Download and run the
rustup-init.exebuilt for thex86_64-pc-windows-msvctarget -
Download the rust nightly compiler (at least v1.45 or higher):
rustup install nightly rustup default nightly -
Clone the repository:
git clone https://github.com/akovacs/uploadserver -
Compile and execute the server:
cd uploadserver cargo run --releaseOr alternatively if you have multiple toolchains installed:
# For Linux x86-64 cargo run --release --target x86_64-unknown-linux-gnu # For Windows x86-64 cargo run --release --target x86_64-pc-windows-msvc -
Browse to port 8000 at your IP address, for example: http://localhost:8000 to upload and download files.
-
Uploaded files will be added to the
uploadsdirectory.
-
Upload files from commandline:
curl -X POST --data-binary @file_to_upload.txt http://localhost:8000/file_to_upload.txt -
Download files from commandline:
curl http://localhost:8000/uploads/file_to_upload.txt --output download.txt wget http://localhost:8000/uploads/file_to_upload.txt -
Password protect files via HTTP Basic Authentication (username: admin, specify 1+ passwords)
# Start uploadserver with password-protected basic authentication cargo run --release -- --password=mypassword # Upload a file using basic authentication with password curl --basic --user admin:mypassword -X POST --data-binary @file_to_upload.txt http://localhost:8000/file_to_upload.txt # Failed attempt to download a file without providing the password wget http://localhost:8000/uploads/file_to_upload.txt # HTTP request sent, awaiting response... 401 Unauthorized # Successful download using basic authentication with password wget --http-user=admin --http-password=mypassword http://0.0.0.0:8000/uploads/file_to_upload.txt # HTTP request sent, awaiting response... 200 OK -
Generate SHA256 hashes for each file in uploads
cargo run --release -- --generate_sha256
-
First time: If this is your first time trying out IPv6, first run the test python webserver
http.serveron port 8001, and verify that you can reach it from your browser via IPv6 at http://[::1]:8001.[::1]is the IPv6 loopback address, equivalent to the IPv4 address127.0.0.1, which refers to the localhost. This sanity check verifies that no firewalls are blocking your browser from connecting to a server running on the same machine. Ctrl+C to terminate the server once you are done testing it.python3 -m http.server 8001 --bind :: -
UploadServer is currently built using an IPv4-based Rocket framework. To access the server using IPv6, you can use the socat relay tool to forward incoming IPv6 connections which are requesting port 8001 to port 8000 on IPv4 localhost (127.0.0.1), and run uploadserver on port 8000.
sudo apt install socat socat TCP6-LISTEN:8001,fork,reuseaddr TCP4:127.0.0.1:8000 -
First time: Then in another terminal instance, start the python IPv4
http.serveron port 8000 to test the socat relay setup:python3 -m http.server 8000 -
If you can reach the IPv4 python http.server through socat by opening http://[::1]:8001 in your browser, then kill the python3
http.serverusing Ctrl+C and start uploadserver on port 8000:cargo run --release -
Final summary: To access the uploadserver, execute the commands posted here, then connect from your browser to port 8001 using IPv6. For example, you can open http://[::1]:8001 in your browser to access uploadserver. Replace
[::1]with the IPv6 address that the server is operating from, in brackets.
The following commands build a statically-linked Linux binary without shared library dependencies. This can be useful when distributing the binary to multiple different Linux distributions or to different versions of a Linux distribution, since libgcc, libc, libpthread, and other dependencies can break due to version changes.
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found
(required by ./uploadserver-x86_64-linux)
Note that performance may be lower than the dynamically-linked binaries described above.
-
Add musl toolchain:
rustup target add x86_64-unknown-linux-musl sudo apt install musl-tools -
Compile Linux binary using the musl toolchain:
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-musl
-
Install the latest version of Xcode from the App Store, or an older XCode version from Apple Developer Downloads.
-
Switch to the specified Xcode version if necessary:
xcode-select --switch /Volumes/YOUR_VOLUME/Applications/Xcode.app -
Configure the minimum supported OS X version (down to 10.7 Lion) in
Cargo.toml:[target.x86_64-apple-darwin] rustflags=["-C", "link-arg=-mmacosx-version-min=10.7"] -
Compile the binary:
MACOSX_DEPLOYMENT_TARGET=10.7 cargo build --target=x86_64-apple-darwin --release
Requires MacOS Catalina 10.15.4 (Intel-based Mac) or MacOS Big Sur 11 (Apple Silicon Mac) or later.
Xcode 12.2 and later is a requirement for building universal binaries. Earlier versions of Xcode don't contain the support needed to build and test universal versions of MacOS code.
- Github: Cargo-Lipo can automatically create universal libraries (fat binaries supporting both Intel x86_64 processors and Apple Silicon) for iOS and Mac.
- Github: Homebrew MacOS Cross-Compilation Toolchains
- Stack Overflow: How do I cross compile a Rust application from macOS x86 to macOS Silicon?
