A simple HTTP file server written in Go that allows you to upload, download, list, and delete files through a web interface.
- π€ Upload files via web interface or curl
- π₯ Download files with a single click
- π List all files with size and modification time
- ποΈ Delete files (optional)
- π Human-readable file sizes
- π Safe filename handling
- πΎ Support for large file uploads (configurable)
fsrv/
βββ cmd/
β βββ fsrv/
β βββ main.go # Main application entry point
βββ internal/
β βββ config/ # Configuration management
β β βββ config.go
β β βββ config_test.go
β βββ handler/ # HTTP request handlers
β β βββ handler.go
β β βββ handler_test.go
β βββ service/ # Business logic layer
β β βββ service.go
β β βββ service_test.go
β βββ util/ # Utility functions
β βββ util.go
β βββ util_test.go
βββ web/
β βββ templates/ # HTML templates
β β βββ files.html
β β βββ info.html
β β βββ upload.html
β βββ fs.go # Embedded filesystem
βββ Makefile
βββ go.mod
βββ go.sum
βββ README.md
βββ .gitignore
# Clone the repository
git clone https://github.com/zxpbenson/fsrv.git
cd fsrv
# Build using Makefile
make build
# Run the application
./build/fsrvgo build -o build/fsrv ./cmd/fsrvgo install github.com/zxpbenson/fsrv/cmd/fsrv@latest./fsrv [options]Options:
-p <port>: Specify the port to listen on (default: 8080)-d: Enable delete file by UI (default: false)-s <directory>: Specify the directory to store files (default: ./store)-n <hostname>: Specify the server name (default: system hostname)-m <size>: Max file size to upload in bits (default: 32, which means 1<<32 = 4GB)
Start server on port 8080:
./fsrvStart server on port 3000 with delete enabled:
./fsrv -p 3000 -dStart server with custom store directory:
./fsrv -s /path/to/storeStart server with max file size of 8GB:
./fsrv -m 33GET /orGET /files: List all filesGET /toUpload: Show upload pagePOST /upload: Upload a fileGET /download?file=<filename>: Download a fileGET /del?file=<filename>: Delete a file (if enabled)
- Open
http://localhost:8080/toUploadin your browser - Select a file and click "Upload"
curl -F 'file=@/path/to/file' http://localhost:8080/upload- Open
http://localhost:8080/filesin your browser - Click on the file you want to download
curl -L -o 'filename' 'http://localhost:8080/download?file=filename'- Open
http://localhost:8080/filesin your browser - Click the "Delete" button next to the file (if delete is enabled)
curl 'http://localhost:8080/del?file=filename'This project includes a Makefile to simplify common development tasks.
make test
# Run tests with coverage report
make test-coverage# Format code
make fmt
# Run linter
make lint
# Run vet
make vetmake build# Build and run
make run
# Or run directly from build
./build/fsrvmake cleanBuild for multiple platforms (Linux/Windows/macOS) at once:
make cross-compileThe application follows a clean architecture pattern:
- Config Layer: Handles configuration parsing and management
- Service Layer: Contains business logic for file operations
- Handler Layer: Handles HTTP requests and responses
- Util Layer: Provides utility functions for common operations
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.