A simple and powerful file server written in Go with support for browsing, uploading, and downloading files with resume capability.
- 📁 File Browsing - Navigate through directories with a clean web interface
- 📤 File Upload - Upload files via web form or drag & drop (both on upload page and browse page)
- 📥 File Download - Download files with resume support (HTTP Range requests)
- 🔒 Security - Path traversal protection to prevent accessing files outside the working directory
- 🎨 Modern UI - Clean and responsive interface
- ⚡ Lightweight - Single binary with embedded templates
Install the latest stable release with the go command:
go install github.com/worthies/files@latestInstall the current tip of the default branch (useful for nightly/testing builds):
go install github.com/worthies/files@masterYou can also download pre-compiled binaries from the nightly releases:
- Go to the Releases page
- Download the appropriate binary for your platform (Windows, Linux, macOS)
- Make the binary executable (on Unix-like systems):
chmod +x files - Move it to a directory in your PATH or run it directly
Notes:
go install ...@latestinstalls the latest released module version.- Installing
@master(or@main) fetches the tip of the branch — treat this as a nightly/edge build. - The installed binary is placed in
$GOBIN(if set) or$(go env GOPATH)/bin; make sure that directory is on yourPATH:
export PATH=$PATH:$(go env GOPATH)/binIf you prefer to build locally:
git clone https://github.com/worthies/files.git
cd files
go build -o files ./...Requirements:
- Go 1.21 or newer (see
go.mod).
Run the server in the current directory on port 8080:
./files./files [options]Options:
-host <address>- Address to listen on (default: 0.0.0.0)-port <port>- Port to listen on (default: 8080)-dir <directory>- Working directory to serve files from (default: current directory)-i <config>- Enable intelligent MIME recognition for browser-viewable multimedia. Usetruefor default mappings, or specify custom mappings in format:ext1,ext2:mime/type;ext3:mime/type2,vwhere,vindicates viewable in browser (optional)-auth <rule>- Enable HTTP Basic authentication and authorization rules. Rules can be in these formats:password— A single password string; any username is accepted if this password matches.username:password— Username and password pair with fullrwaccess.username:password:permission:pattern— Username, password, permission (one ofr,w,rw), and a glob-style pattern describing the path(s) this rule affects (e.g.,public/*,*.txt). Patterns are converted to a regular expression and anchored against the entire path.- The
-authflag may be provided multiple times, and each flag value can contain multiple comma-separated rules (e.g.,-auth "u1:p1,u2:p2"). When any auth rule matches, access is granted according to matched permissions.
Run on custom port:
./files -port 9000Listen only on localhost:
./files -host 127.0.0.1Serve files from a specific directory:
./files -dir /path/to/filesCombine options:
./files -host 192.168.1.100 -port 9000 -dir /path/to/filesEnable intelligent MIME recognition:
./files -i trueEnable intelligent MIME recognition with custom MIME type mappings:
# Map .mhtml, .shtml to text/html (viewable in browser)
./files -i "mhtml,shtml:text/html,v"
# Multiple mappings with different MIME types
./files -i "mhtml,shtml:text/html,v;custom:application/custom;doc:application/msword"
# Mix viewable and non-viewable types
./files -i "mhtml,shtml:text/html,v;archive:application/x-archive"Enable intelligent MIME recognition with other options:
./files -i true -port 9000 -dir /path/to/files
./files -i "mhtml,shtml:text/html,v" -port 9000 -dir /path/to/files- All HTTP requests are logged to console with method, path, and client IP address
- Request completion time is displayed for performance monitoring
- Useful for debugging and monitoring server activity
- Navigate through directories using the web interface
- View file sizes and modification times
- Breadcrumb navigation for easy path traversal
- Click "Upload File" button
- Select a file or drag and drop onto the upload area
- Optionally specify a subdirectory
- Upload progress indicator shows transfer status
You can also drag and drop files directly onto the browse page!
- Click on any file to download it
- Resume support: Partial downloads can be resumed if interrupted
- Automatic file name preservation
When enabled with -i, the server intelligently recognizes file types and serves them inline in the browser when appropriate:
- Default mode (
-i true): Recognizes common multimedia and document types (images, audio, video, PDF, HTML, etc.) - Custom mappings: Map file extensions to custom MIME types with optional viewability control
- Example:
jpg,png:image/jpeg,vmaps .jpg and .png files to image/jpeg and marks as viewable - Non-viewable types:
zip:application/zipwill download the file - Viewable types marked with
,v: served inline in browser - Without
,v: serves as attachment (download)
- Example:
- Path traversal protection prevents accessing files outside the configured directory
- All paths are validated and sanitized
- No execution of uploaded files
- The server supports HTTP Basic authentication using the
-authcommand-line flag. When authentication is enabled by providing at least one-authrule, the server requires valid credentials on every request. - Rules are evaluated in order; a user is authorized if any rule's username/password matches and the requested path is permitted by that rule.
rpermission is required to browse or download files;wpermission is required to upload files. If a rule has no pattern, it applies to the entire served tree.
Examples:
# Accept any username with the password "secret123"
./files -auth "secret123"
# Add two accounts with full access
./files -auth "admin:adminpass" -auth "user:userpass"
# A read-only user limited to *.txt under the public directory
./files -auth "reader:readpass:r:public/*.txt"
# Comma-separated rules in a single flag
./files -auth "user1:pass1,user2:pass2,guest:guestpass:r:public/*"GET /- Browse files in the current directoryGET /<path>- Browse files in a specific directoryGET /download/<path>- Download a file (supports HTTP Range requests)GET /upload- Display upload formPOST /upload- Handle file upload
- Language: Go
- Dependencies: Standard library only
- Templates: Embedded in binary using
embedpackage - HTTP Features: Range requests for resume support
- Maximum upload size: 100MB in memory
See LICENSE file for details.