如何从命令lin使用Seafile生成的uploadlink,不带身份验证令牌

2024-06-16 12:45:47 发布

您现在位置:Python中文网/ 问答频道 /正文

有了Seafile,用户可以创建一个公共上传链接(例如https://cloud.seafile.com/u/d/98233edf89/),通过浏览器上传文件,而不需要认证。在

Seafile webapi不支持任何不带身份验证令牌的上载。在

如何从命令行和curl或python脚本中使用这种链接?在


Tags: 文件命令行用户https脚本com身份验证cloud
1条回答
网友
1楼 · 发布于 2024-06-16 12:45:47

需要2小时才能找到curl的解决方案,需要两个步骤:

  1. 使用repo-id作为查询参数对公共上行链路url发出get请求,如下所示:

curl 'https://cloud.seafile.com/ajax/u/d/98233edf89/upload/?r=f3e30b25-aad7-4e92-b6fd-4665760dd6f5' -H 'Accept: application/json' -H 'X-Requested-With: XMLHttpRequest'

答案是(json)在下一个上传帖子中使用的id链接,例如:

{"url": "https://cloud.seafile.com/seafhttp/upload-aj/c2b6d367-22e4-4819-a5fb-6a8f9d783680"}

  1. 使用此链接启动上载帖子:

curl 'https://cloud.seafile.com/seafhttp/upload-aj/c2b6d367-22e4-4819-a5fb-6a8f9d783680' -F file=@./tmp/index.html -F filename=index.html -F parent_dir="/my-repo-dir/"

答案又是json

[{"name": "index.html", "id": "0a0742facf24226a2901d258a1c95e369210bcf3", "size": 10521}]

完成;)

相关问题 更多 >