|
@@ -19,22 +19,17 @@ class GetResizedFile(View):
|
|
|
# pylint: disable=arguments-differ
|
|
|
methods = ['GET']
|
|
|
|
|
|
- def dispatch_request(self, file_id: int, resolution: str):
|
|
|
+ def dispatch_request(self, file_id: int, max_width: int, max_height: int = 2**24):
|
|
|
# get file from database
|
|
|
file = File.query.get(file_id)
|
|
|
if file is None:
|
|
|
- return abort(404, "file object not found")
|
|
|
+ abort(404, "file object not found")
|
|
|
|
|
|
if not os.path.exists(file.path):
|
|
|
- return abort(404, "image not found!")
|
|
|
+ abort(404, "image not found!")
|
|
|
|
|
|
project = file.project
|
|
|
|
|
|
- # extract desired resolution
|
|
|
- resolution = re.split(r'[^0-9]', resolution)
|
|
|
- max_width = int(resolution[0])
|
|
|
- max_height = int(resolution[1]) if len(resolution) > 1 else 2 ** 24
|
|
|
-
|
|
|
# send data
|
|
|
file_directory, file_name = tpool.execute(resize_file,
|
|
|
project.id, file.id, max_width, max_height)
|