-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01ab123
commit aabb03d
Showing
4 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests | ||
import urllib.request | ||
import urllib.parse | ||
|
||
from seaserv import seafile_api | ||
import seatable_thumbnail.settings as settings | ||
from seatable_thumbnail.constants import EMPTY_BYTES | ||
|
||
|
||
class Plugin(object): | ||
def __init__(self, **info): | ||
self.__dict__.update(info) | ||
self.body = EMPTY_BYTES | ||
self.get() | ||
|
||
def get(self): | ||
self.get_inner_path() | ||
response = requests.get(self.inner_path) | ||
self.body = response.content | ||
|
||
def get_inner_path(self): | ||
token = seafile_api.get_fileserver_access_token( | ||
settings.PLUGINS_REPO_ID, self.file_id, 'view', '', use_onetime=True) | ||
if not token: | ||
raise ValueError(404, 'token not found.') | ||
self.inner_path = '%s/files/%s/%s' % ( | ||
settings.INNER_FILE_SERVER_ROOT.rstrip('/'), token, urllib.parse.quote(self.file_path.lstrip('/'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters