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 | sh
On Windows: Download and run the
rustup-init.exe
built for thex86_64-pc-windows-msvc
target -
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 --release
Or 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
uploads
directory.
-
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
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?