Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a Seafile generated upload-link w/o authentication token from command line

With Seafile one is able to create a public upload link (e.g. https://cloud.seafile.com/u/d/98233edf89/) to upload files via Browser w/o authentication.

Seafile webapi does not support any upload w/o authentication token.

How can I use such kind of link from command line with curl or from python script?

like image 790
lmen6e Avatar asked Aug 03 '16 11:08

lmen6e


1 Answers

needed 2 hours to find a solution with curl, it needs two steps:

  1. make a get-request to the public uplink url with the repo-id as query parameter as follows:

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'

The answer is (json) a id-link to use in next upload-post e.g.:

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

  1. Use this link to initiate the upload post:

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/"

The answer is json again, e.g.

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

done ;)

like image 88
lmen6e Avatar answered Oct 05 '22 02:10

lmen6e