Skip to content

About

Simple Rust file server which lets you upload, share, and download files from a web browser. Ready-to-run binaries for Windows, Mac, and Linux. Free/Open-Source alternative to AirDrop/Dropbox for transferring files on your local network without having to install anything. A more sophisticated version of `python3 -m http.server 8000`.

Topics

Resources

Stars

70 stars

Watchers

2 watching

Forks

Latest commit

 

History

43 Commits

Folders and files

Repository files navigation

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.

Ready-to-run Binaries

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.

Setup Rust Toolchain and Compile for your machine

  1. 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 the x86_64-pc-windows-msvc target

  2. Download the rust nightly compiler (at least v1.45 or higher):

     rustup install nightly
     rustup default nightly
    
  3. Clone the repository:

     git clone https://github.com/akovacs/uploadserver
    
  4. 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
    
  5. Browse to port 8000 at your IP address, for example: http://localhost:8000 to upload and download files.

    Upload server web interface

  6. Uploaded files will be added to the uploads directory.

Advanced

  • 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
    

Using UploadServer with IPv6 Addressing

  • First time: If this is your first time trying out IPv6, first run the test python webserver http.server on 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 address 127.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.server on 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.server using 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.

Statically-Linked Linux Binary

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.

  1. Add musl toolchain:

     rustup target add x86_64-unknown-linux-musl
     sudo apt install musl-tools
    
  2. Compile Linux binary using the musl toolchain:

     RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-musl
    

Compile for Old Versions of Mac OS X

  1. Install the latest version of Xcode from the App Store, or an older XCode version from Apple Developer Downloads.

  2. Switch to the specified Xcode version if necessary:

     xcode-select --switch /Volumes/YOUR_VOLUME/Applications/Xcode.app
    
  3. 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"]
    
  4. Compile the binary:

     MACOSX_DEPLOYMENT_TARGET=10.7 cargo build --target=x86_64-apple-darwin --release
    

TODO: Support ARM Apple Silicon (M1 processor family)

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.

Further Info

About

Simple Rust file server which lets you upload, share, and download files from a web browser. Ready-to-run binaries for Windows, Mac, and Linux. Free/Open-Source alternative to AirDrop/Dropbox for transferring files on your local network without having to install anything. A more sophisticated version of `python3 -m http.server 8000`.

Topics

Resources

Stars

70 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages