前言
當你需要分享本地 Video, Music, Photos ...,但卻不知道通過何種方式將資源分享出來,這款輕量級 Rust 靜態檔案服務 (dufs) 就很適合你。
不管是將其直接掛載到 kodi, infuse, potplayer ...,還是將其掛載到 openlist 都是可以的。
安裝方式
- With cargo
cargo install dufs
- With docker (推薦)
docker run -v `pwd`:/data -p 5000:5000 --rm sigoden/dufs /data -A
- With Homebrew
brew install dufs
權限控制
$ sudo docker run -d --name dufs \
-v `pwd`/data:/data \
-u $(id -u):$(id -g) \
-p 5000:5000 \
sigoden/dufs /data -A -a admin:admin@/:rw -a user:pass@/src:rw,/share -a @/
- admin - 擁有所有路徑的完整權限
- user - /src 路徑可讀寫, /share 路徑只讀
- 匿名用戶 - 所有路徑只讀
進階
通過 API 使用 cURL
- 上傳文件
curl -T path-to-file http://127.0.0.1:5000/new-path/path-to-file
- 下載文件
curl http://127.0.0.1:5000/path-to-file # download the file
curl http://127.0.0.1:5000/path-to-file?hash # retrieve the sha256 hash of the file
- 下載文件夾為 .zip
curl -o path-to-folder.zip http://127.0.0.1:5000/path-to-folder?zip
- 刪除文件/文件夾
curl -X DELETE http://127.0.0.1:5000/path-to-file-or-folder
- 創建文件夾
curl -X MKCOL http://127.0.0.1:5000/path-to-folder
- 移動文件/文件夾到新的目錄
curl -X MOVE http://127.0.0.1:5000/path -H "Destination: http://127.0.0.1:5000/new-path"
- 搜尋目錄下的文件
curl http://127.0.0.1:5000?q=Dockerfile # search for files, similar to `find -name Dockerfile`
curl http://127.0.0.1:5000?simple # output names only, similar to `ls -1`
curl http://127.0.0.1:5000?json # output paths in json format
- 需身份驗證下載文件
curl http://127.0.0.1:5000/file --user user:pass # basic auth
curl http://127.0.0.1:5000/file --user user:pass --digest # digest auth
- 下載重傳
curl -C- -o file http://127.0.0.1:5000/file
- 上傳重傳
upload_offset=$(curl -I -s http://127.0.0.1:5000/file | tr -d '\r' | sed -n 's/content-length: //p')
dd skip=$upload_offset if=file status=none ibs=1 | \
curl -X PATCH -H "X-Update-Range: append" --data-binary @- http://127.0.0.1:5000/file
- 安全檢查
curl http://127.0.0.1:5000/__dufs__/health
绑定
正在用这个。特别轻量,docker安装才5M。用来临时分享文件特别方便