logo NodeSeekbeta

[分享] Dufs 支援靜態檔案服務、檔案上傳、搜尋、存取控制、WebDAV 等功能。

前言

當你需要分享本地 Video, Music, Photos ...,但卻不知道通過何種方式將資源分享出來,這款輕量級 Rust 靜態檔案服務 (dufs) 就很適合你。

不管是將其直接掛載到 kodi, infuse, potplayer ...,還是將其掛載到 openlist 都是可以的。

安裝方式

  1. With cargo

cargo install dufs

  1. With docker (推薦)
docker run -v `pwd`:/data -p 5000:5000 --rm sigoden/dufs /data -A
  1. 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

  1. 上傳文件

curl -T path-to-file http://127.0.0.1:5000/new-path/path-to-file

  1. 下載文件
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
  1. 下載文件夾為 .zip
curl -o path-to-folder.zip http://127.0.0.1:5000/path-to-folder?zip
  1. 刪除文件/文件夾
curl -X DELETE http://127.0.0.1:5000/path-to-file-or-folder
  1. 創建文件夾
curl -X MKCOL http://127.0.0.1:5000/path-to-folder
  1. 移動文件/文件夾到新的目錄
curl -X MOVE http://127.0.0.1:5000/path -H "Destination: http://127.0.0.1:5000/new-path"
  1. 搜尋目錄下的文件
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
  1. 需身份驗證下載文件
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
  1. 下載重傳
curl -C- -o file http://127.0.0.1:5000/file
  1. 上傳重傳
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
  1. 安全檢查
curl http://127.0.0.1:5000/__dufs__/health

References

  • 绑定

  • 正在用这个。特别轻量,docker安装才5M。用来临时分享文件特别方便

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

📈用户数目📈

目前论坛共有72661位seeker

🎉欢迎新用户🎉