From 937047417600a0e47346a71f34d7274d6aca51bc Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 23 Sep 2025 09:53:47 +0800 Subject: [PATCH] bugfix --- appPublic/base64_to_file.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/appPublic/base64_to_file.py b/appPublic/base64_to_file.py index a3befa6..71c9bc9 100644 --- a/appPublic/base64_to_file.py +++ b/appPublic/base64_to_file.py @@ -60,11 +60,12 @@ def hex2base64(hex_str, typ): def getFilenameFromBase64(base64String): match = re.match(r"data:(.*?);base64,(.*)", base64String) + name = getID() if not match: - raise ValueError("不是合法的 base64 Data URL") + # raise ValueError("不是合法的 base64 Data URL") + return name mime_type, b64_data = match.groups() ext = MIME_EXT.get(mime_type, mime_type.split("/")[-1]) - name = getID() fname = f'{name}.{ext}' return fname @@ -81,3 +82,5 @@ def base64_to_file(base64_string, output_path): # Write binary data to file with open(output_path, 'wb') as file: file.write(binary_data) + +def base642file(base64string)