今天分享一个非常实用的开源工具:Dufs,就如我们前面讲过的CHFS,它完美解决了在团队内部快速共享和管理文件的难题。

Dufs 是一个用 Rust 语言开发的轻量级文件服务器,只需一行命令即可启动。

Dufs 支持文件上传下载、在线预览、权限控制等丰富功能,而且部署极其简单,非常适合团队内部快速搭建文件共享服务。

主要功能

  1. 文件管理:
  • 支持拖拽上传文件和文件夹
  • 支持在线创建、编辑、搜索文件
  • 支持 WebDAV 协议,可与其他工具协同工作
  1. 文件服务:
  • 支持静态文件服务,可直接浏览和下载文件
  • 支持将文件夹打包成 zip 下载
  • 支持断点续传,大文件传输更稳定
  • 支持直接预览 HTML 网站
  1. 安全特性:
  • 支持用户认证和访问控制
  • 支持 HTTPS 加密传输
  • 支持隐藏指定文件和目录

安装指南

安装 Dufs 非常简单,只需几步就能完成部署:

  • 使用 Docker 一键部署:
docker run -v `pwd`:/data -p 5000:5000 --rm sigoden/dufs /data -A
  • 下载安装包安装

访问其 GitHub 发布页面,下载对应系统的安装包,解压后将可执行文件添加到系统环境变量即可,支持 Windows、macOS 和 Linux 系统。

使用方法

Dufs is a distinctive utility file server - https://github.com/sigoden/dufs

Usage: dufs [OPTIONS] [serve-path]

Arguments: [serve-path] Specific path to serve [default: .]

Options:

-c, --config Specify configuration file

-b, --bind Specify bind address or unix socket

-p, --port Specify port to listen on [default: 5000]

--path-prefix Specify a path prefix

--hidden Hide paths from directory listings, e.g. tmp,.log,.lock

-a, --auth Add auth roles, e.g. user:pass@/dir1:rw,/dir2

-A, --allow-all Allow all operations

--allow-upload Allow upload files/folders

--allow-delete Allow delete files/folders

--allow-search Allow search files/folders

--allow-symlink Allow symlink to files/folders outside root directory

--allow-archive Allow download folders as archive file

--enable-cors Enable CORS, sets Access-Control-Allow-Origin: *

--render-index Serve index.html when requesting a directory, returns 404 if not found index.html

--render-try-index Serve index.html when requesting a directory, returns directory listing if not found index.html

--render-spa Serve SPA(Single Page Application)

--assets Set the path to the assets directory for overriding the built-in assets

--log-format Customize http log format

--log-file Specify the file to save logs to, other than stdout/stderr

--compress Set zip compress level [default: low] [possible values: none, low, medium, high]

--completions Print shell completion script for [possible values: bash, elvish, fish, powershell, zsh]

--tls-cert Path to an SSL/TLS certificate to serve with HTTPS

--tls-key Path to the SSL/TLS certificate's private key

-h, --help Print help

-V, --version Print version

使用举例:

  • 以只读模式共享当前目录:
dufs
  • 允许所有操作(上传、删除、搜索等):
dufs -A
  • 设置用户名密码访问:
dufs -a admin:123@/:rw

更多使用方法参见项目地址:https://github.com/sigoden/dufs