gpt4 book ai didi

python - 如何从命令行使用 Seafile 生成的不带身份验证 token 的上传链接

转载 作者:太空宇宙 更新时间:2023-11-03 13:36:33 26 4
gpt4 key购买 nike

使用 Seafile 可以创建一个公共(public)上传链接(例如 https://cloud.seafile.com/u/d/98233edf89/)以通过浏览器上传文件而无需身份验证。

Seafile webapi 不支持任何没有身份验证 token 的上传。

我如何通过 curl 命令行或 python 脚本使用此类链接?

最佳答案

用curl找到解决方案需要2个小时,需要两步:

  1. 使用 repo-id 作为查询参数向公共(public)上行链路 url 发出获取请求,如下所示:

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-link,例如:

{"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}]

完成;)

关于python - 如何从命令行使用 Seafile 生成的不带身份验证 token 的上传链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38742893/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com