From 12a5dd8fdeab09b161ef27d62f92d9253988ea13 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 26 Sep 2023 11:13:48 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20handle=20cases?= =?UTF-8?q?=20where=20file.filename=20is=20not=20a=20string=20or=20Path=20?= =?UTF-8?q?object=20to=20prevent=20errors=20=F0=9F=94=A7=20chore(utils.py)?= =?UTF-8?q?:=20refactor=20save=5Fuploaded=5Ffile=20function=20to=20improve?= =?UTF-8?q?=20code=20readability=20and=20maintainability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/services/cache/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/services/cache/utils.py b/src/backend/langflow/services/cache/utils.py index 75380b3d5..83cde2240 100644 --- a/src/backend/langflow/services/cache/utils.py +++ b/src/backend/langflow/services/cache/utils.py @@ -169,7 +169,11 @@ def save_uploaded_file(file: UploadFile, folder_name): """ cache_path = Path(CACHE_DIR) folder_path = cache_path / folder_name - file_extension = Path(file.filename).suffix + filename = file.filename + if isinstance(filename, str) or isinstance(filename, Path): + file_extension = Path(filename).suffix + else: + file_extension = "" file_object = file.file # Create the folder if it doesn't exist