1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 23:02:26 +00:00

[thumbnail] add THUMBNAIL_IMAGE_SIZE_LIMIT

This commit is contained in:
lian
2015-03-13 15:28:29 +08:00
parent f8ba28f723
commit cb4ffdfcce
8 changed files with 114 additions and 82 deletions

View File

@@ -1,5 +1,24 @@
import posixpath
from seahub.utils import get_service_url
from seaserv import seafile_api
from seahub.utils import get_service_url, get_file_type_and_ext
from seahub.utils.file_types import IMAGE
from seahub.settings import ENABLE_THUMBNAIL, THUMBNAIL_IMAGE_SIZE_LIMIT
def get_thumbnail_src(repo_id, obj_id, size):
return posixpath.join(get_service_url(), "thumbnail", repo_id,
obj_id, size) + "/"
def allow_generate_thumbnail(username, repo, f):
# check if thumbnail is allowed
if seafile_api.check_repo_access_permission(repo.id, username) is None:
# user can not access repo
return False
file_type, file_ext = get_file_type_and_ext(f.obj_name)
if not repo.encrypted and file_type == IMAGE and ENABLE_THUMBNAIL \
and f.file_size < THUMBNAIL_IMAGE_SIZE_LIMIT * 1024**2:
return True
else:
return False