Compare commits

..

2 Commits
0.2 ... py3

Author SHA1 Message Date
shim_
69578e4281 laid base for expiring links 2018-10-04 18:05:23 +02:00
shim_
2344c7b8af better api support 2018-10-04 18:02:13 +02:00
2 changed files with 11 additions and 2 deletions

View File

@ -98,10 +98,15 @@ class SeafileFile:
self.size = size self.size = size
#curl -v -X PUT -d "p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/afc3b694-7d4c-4b8a-86a4-89c9f3261b12/file/shared-link/ #curl -v -X PUT -d "p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/afc3b694-7d4c-4b8a-86a4-89c9f3261b12/file/shared-link/
def share(self): def share(self,expire=None,password=None):
parameters = {'p': self.path }
if expiry:
parameters['expire'] = int(expire)
if password:
parameters['password'] = str(password)
resp = self.session.put("%s/repos/%s/file/shared-link/" % (self.library.client.api_endpoint(),self.library.id), resp = self.session.put("%s/repos/%s/file/shared-link/" % (self.library.client.api_endpoint(),self.library.id),
headers = {'Authorization': "Token %s" % self.library.client.token.token, 'Accept': 'application/json; indent=4'}, headers = {'Authorization': "Token %s" % self.library.client.token.token, 'Accept': 'application/json; indent=4'},
data = {'p': self.path} data = parameters
) )
return resp.headers.get("location") return resp.headers.get("location")

View File

@ -23,6 +23,7 @@ class SeafileUploader():
self.loadSettings() self.loadSettings()
self.pool = Pool(2) self.pool = Pool(2)
self.seaf_client = None self.seaf_client = None
self.link_expiry = None
def showSettingsUI(self, parentWidget): def showSettingsUI(self, parentWidget):
self.parentWidget = parentWidget self.parentWidget = parentWidget
@ -78,6 +79,7 @@ class SeafileUploader():
(self.lib_id,self.lib_name) = str(settings.value("library", "/")).split("/") (self.lib_id,self.lib_name) = str(settings.value("library", "/")).split("/")
self.lib_path = settings.value("library-path", "") self.lib_path = settings.value("library-path", "")
self.copyLink = settings.value("copy-link", "true") in ['true', True] self.copyLink = settings.value("copy-link", "true") in ['true', True]
self.link_expiry = settings.value("link-expiry", None)
if settings.value("auth-token", False) and settings.value("auth-username", False): if settings.value("auth-token", False) and settings.value("auth-username", False):
self.access_token = SeafileToken(settings.value("auth-username", False),settings.value("auth-token", False)) self.access_token = SeafileToken(settings.value("auth-username", False),settings.value("auth-token", False))
else: else:
@ -105,6 +107,8 @@ class SeafileUploader():
except: except:
pass pass
settings.setValue("copy-link", self.copyLink) settings.setValue("copy-link", self.copyLink)
if self.link_expiry:
settings.setValue("link-expiry", self.link_expiry)
if self.access_token is not None: if self.access_token is not None:
settings.setValue("auth-username", self.access_token.username ) settings.setValue("auth-username", self.access_token.username )
settings.setValue("auth-token", self.access_token.token) settings.setValue("auth-token", self.access_token.token)