From f8a8218149d106e173cd152fd0d07479afcc17e8 Mon Sep 17 00:00:00 2001 From: Patrick Deniso Date: Fri, 7 Feb 2025 14:42:16 -0500 Subject: [PATCH] fix bug where '/' was not properly inserted in s3 key strings --- backend/open_webui/storage/provider.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/storage/provider.py b/backend/open_webui/storage/provider.py index f287daf2f..afc50b397 100644 --- a/backend/open_webui/storage/provider.py +++ b/backend/open_webui/storage/provider.py @@ -94,7 +94,7 @@ class S3StorageProvider(StorageProvider): aws_secret_access_key=S3_SECRET_ACCESS_KEY, ) self.bucket_name = S3_BUCKET_NAME - self.key_prefix = S3_KEY_PREFIX + self.key_prefix = S3_KEY_PREFIX if S3_KEY_PREFIX else "" def upload_file(self, file: BinaryIO, filename: str) -> Tuple[bytes, str]: """Handles uploading of the file to S3 storage.""" @@ -150,7 +150,7 @@ class S3StorageProvider(StorageProvider): # The s3 key is the name assigned to an object. It excludes the bucket name, but includes the internal path and the file name. def _extract_s3_key(self, full_file_path: str) -> str: - return ''.join(full_file_path.split("//")[1].split("/")[1:]) + return '/'.join(full_file_path.split("//")[1].split("/")[1:]) def _get_local_file_path(self, s3_key: str) -> str: return f"{UPLOAD_DIR}/{s3_key.split('/')[-1]}"