Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 2.13 KB

README.md

File metadata and controls

50 lines (40 loc) · 2.13 KB

rustor

A simple file server to learn rust and warp.

Note: This is a learner's project and is not remotely usable.

This can probably be implemented in a simpler way using warp::fs::dir, but where's the fun in that.

Build and run

  • Required: Edit the BASE_FOLDER in handlers.rs to point to the folder you want to serve. (I know this is suboptimal).
  • Change the IP (say from 0.0.0.0 to 127.0.0.1) and Port (say 3030 to 8080) per your needs. (Again, suboptimal and should ideally be read from a config file)
  • Run cargo run
  • Experimental in-progress UI can be accessed by running pnpm dev or npm dev in sapper folder (Backend must be on localhost:3030)
  • Even more experimental and in-progress UI can be accessed by running pnpm dev or npm dev in sveltekit folder (Backend must be on localhost:3030)

API

  • Stable webUI can be accessed at http://IP_IN_RUST:PORT_IN_RUST/web/ls
  • Experimental UIs can be accessed at http://IP_IN_SAPPER:PORT_IN_SAPPER/files
  • Fetch the list of directories at my/dir -> GET http://IP:PORT/api/ls?path=my%2Fdir
  • Download the file at my/dir/file.ext -> GET http://IP:PORT/api/download?path=my%2Fdir%2Ffile.ext
  • Delete the file/folder at my/dir/rec -> GET http://IP:PORT/api/rm?path=my%2Fdir%2Frec

Capabilities / Features

  • File and path sanitization to prevent directory attacks.
  • View and traverse folders
  • Download files
  • Create folders
  • Delete folders and files
  • Upload files (tested with file size of ~ 12GB on localhost)
  • Multi tenant and auth
  • Rename dir / file
  • Move file / dir

Todos

  • Code Cleanup, Import Optimization
  • Logging

Dependencies

  • warp, hyper, tokio for the basic web server / concurrency stuff.
  • sailfish for web templating.
  • svelte / sapper for experimental UIs.
  • Other helper libs.

Thanks

  • miniserve for parts of code mainly HTML / CSS / JS

Usable Open Source Alternatives