diff --git a/imports/seafapi.py b/imports/seafapi.py index c8d9353..eafe320 100644 --- a/imports/seafapi.py +++ b/imports/seafapi.py @@ -111,11 +111,14 @@ class SeafileFile: 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/ - def share(self): + def share(self,expire_days=None): + data = {'p': self.path} + if expire_days and not expire_days == 0: + data['expire'] = expire_days 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'}, - data={'p': self.path} + data = data ) return resp.headers.get("location") diff --git a/imports/settings.py b/imports/settings.py index 4d0f8b8..1b13d6f 100644 --- a/imports/settings.py +++ b/imports/settings.py @@ -11,6 +11,7 @@ class SeafScreencloudSettings: self.token = None # SefileToken self.upload_scheme = "regular" self.url = None + self.link_expiry = None def _client(self): if self.token and self.url: @@ -28,6 +29,7 @@ class SeafScreencloudSettings: self.client = self._client self.url = settings.value("seafile-url", None) + self.link_expiry = int(settings.value("link-expiry", None)) lib = tuple(settings.value("library", "/").split("/")) (id, name) = lib if len(id) == 0 or self.client() == None: @@ -64,6 +66,8 @@ class SeafScreencloudSettings: if self.library is not None: settings.setValue("library", "%s/%s" % (self.library.id, self.library.name)) + if self.link_expiry is not None: + settings.setValue("link-expiry", self.link_expiry) settings.setValue("library-path", self.library_path) if self.token != None: settings.setValue("auth-username", self.token.username)