lme*_*n6e 4 python curl urllib2 http-upload seafile-server
借助Seafile,人们可以创建公共上传链接(例如https://cloud.seafile.com/u/d/98233edf89/),以通过不带身份验证的浏览器上传文件。
Seafile webapi不支持任何不带身份验证令牌的上传。
我该如何使用curl或python脚本从命令行使用此类链接?
需要2个小时才能找到卷曲的解决方案,它需要两个步骤:
repo-idas查询参数对公共上行链路URL进行get-request,如下所示: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"}
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}]
完成;)