获取 seafile 分享的文件直链

创建一个带有效期的分享文件的链接,比如 http://192.168.1.29:8088/f/266c337aab4c40598023/

点击即下载的直链是 http://192.168.1.29:8088/f/266c337aab4c40598023/?dl=1

但这些都还需要 js 运行后下载器才能获取到文件的直链。之前更新 Mattermost 后端需要下载最新版的 mm 压缩包程序,由于官网太慢,我就下载到了本地然后通过公网的 seafile 分享了个链接,试图修改 Dockerfile 让 curl 直接下载文件,最终找到了文件直链。

$ curl -vv http://192.168.1.29:8088/f/266c337aab4c40598023/?dl=1
*   Trying 192.168.1.29...
* TCP_NODELAY set
* Connected to 192.168.1.29 (192.168.1.29) port 8088 (#0)
> GET /f/266c337aab4c40598023/?dl=1 HTTP/1.1
> Host: 192.168.1.29:8088
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Server: nginx/1.18.0 (Ubuntu)
< Date: Wed, 22 Feb 2023 01:46:28 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< Location: http://192.168.1.29:8088/seafhttp/files/ab1a6620-1623-41e2-8838-3920199694e3/Snipaste_2022-06-09_11-02-04.png
< Vary: Cookie, Accept-Language
< Content-Language: en
< Set-Cookie: sfcsrftoken=FoZm3c677QZ3S99XuZe17Wl8wivMUBafSYH02DMBxFTsZcq7V4o5IMCxHzteWfr0; expires=Wed, 21 Feb 2024 01:46:28 GMT; Max-Age=31449600; Path=/; SameSite=Lax
<
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.1.29 left intact

可以看到 curl 之后 HTTP/1.1 302 Found,目标路径 location 是 http://192.168.1.29:8088/seafhttp/files/ab1a6620-1623-41e2-8838-3920199694e3/Snipaste_2022-06-09_11-02-04.png,这个就是文件直链。但在有效期过了之后文件直链便不可访问了。

添加新评论