|
@@ -18,7 +18,7 @@ from psycopg.rows import TupleRow
|
|
from linkpreview import link_preview
|
|
from linkpreview import link_preview
|
|
|
|
|
|
from .qr import get_qr_code
|
|
from .qr import get_qr_code
|
|
-from .validate import get_file_mimetype, get_filename, validate, validate_file, validate_parameter, validate_url
|
|
|
|
|
|
+from .validate import get_file_mimetype, get_file_size, get_filename, validate, validate_file, validate_parameter, validate_url
|
|
from .hash_util import normalize_base32
|
|
from .hash_util import normalize_base32
|
|
from .route_decorators import normalize, poison, cursor
|
|
from .route_decorators import normalize, poison, cursor
|
|
from .query_to_xml import get_categories, get_groups, get_products, get_tags
|
|
from .query_to_xml import get_categories, get_groups, get_products, get_tags
|
|
@@ -179,8 +179,11 @@ def upload():
|
|
mimetype = None
|
|
mimetype = None
|
|
if _hash:
|
|
if _hash:
|
|
_hash = normalize_base32(_hash)
|
|
_hash = normalize_base32(_hash)
|
|
|
|
+ size = get_file_size(_hash)
|
|
name = get_filename(_hash)
|
|
name = get_filename(_hash)
|
|
mimetype = get_file_mimetype(name)
|
|
mimetype = get_file_mimetype(name)
|
|
|
|
+ if mimetype is not True and mimetype.startswith('text'):
|
|
|
|
+ mimetype = None if size > CLIP_SIZE_LIMIT else mimetype
|
|
|
|
|
|
link = f'{LOCATION}/upload/{_hash}' if _hash else f'{LOCATION}/upload'
|
|
link = f'{LOCATION}/upload/{_hash}' if _hash else f'{LOCATION}/upload'
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
@@ -206,10 +209,12 @@ def upload():
|
|
def get_upload(filename):
|
|
def get_upload(filename):
|
|
filename = filename and normalize_base32(filename)
|
|
filename = filename and normalize_base32(filename)
|
|
download = True
|
|
download = True
|
|
|
|
+ mimetype = True
|
|
if request.params.download == "false":
|
|
if request.params.download == "false":
|
|
download = False
|
|
download = False
|
|
|
|
+ mimetype = request.params.mimetype or None
|
|
|
|
|
|
- return validate_file(filename, download=download)
|
|
|
|
|
|
+ return validate_file(filename, download=download, mimetype=mimetype)
|
|
|
|
|
|
|
|
|
|
@route('/goto', method=['GET', 'POST'])
|
|
@route('/goto', method=['GET', 'POST'])
|