From 6a4858a7ee5ea17d31e88b91c74b9f0b9cc02439 Mon Sep 17 00:00:00 2001 From: wwwlll Date: Tue, 22 Oct 2024 09:21:05 +0800 Subject: [PATCH] Fix thumbnail_img NoneType error (#2941) ### What problem does this PR solve? fix thumbnail_img NoneType error ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/utils/file_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/utils/file_utils.py b/api/utils/file_utils.py index 2428f3f21..32ead6cc7 100644 --- a/api/utils/file_utils.py +++ b/api/utils/file_utils.py @@ -199,8 +199,11 @@ def thumbnail_img(filename, blob): def thumbnail(filename, blob): img = thumbnail_img(filename, blob) - return IMG_BASE64_PREFIX + \ - base64.b64encode(img).decode("utf-8") + if img is not None: + return IMG_BASE64_PREFIX + \ + base64.b64encode(img).decode("utf-8") + else: + return '' def traversal_files(base): for root, ds, fs in os.walk(base):