From fd97ce3e5a40d8505282973b13ea7f9a102f99d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=9B=E9=9C=B2=E5=85=88=E7=94=9F?= Date: Thu, 17 Jul 2025 12:10:15 +0800 Subject: [PATCH] fix s3 init config . (#8886) ### What problem does this PR solve? when``` if 'signature_version' in self.s3_config:``` and ```if 'addressing_style' in self.s3_config:``` both true. the config init is error, will be overwrite by last one. this pr is for fix that case. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Signed-off-by: zhanluxianshen --- rag/utils/s3_conn.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rag/utils/s3_conn.py b/rag/utils/s3_conn.py index bccfd91fc..6c9170451 100644 --- a/rag/utils/s3_conn.py +++ b/rag/utils/s3_conn.py @@ -66,6 +66,7 @@ class RAGFlowS3: try: s3_params = {} + config_kwargs = {} # if not set ak/sk, boto3 s3 client would try several ways to do the authentication # see doc: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials if self.access_key and self.secret_key: @@ -78,9 +79,12 @@ class RAGFlowS3: if 'endpoint_url' in self.s3_config: s3_params['endpoint_url'] = self.endpoint_url if 'signature_version' in self.s3_config: - s3_params['config'] = Config(s3={"signature_version": self.signature_version}) + config_kwargs['signature_version'] = self.signature_version if 'addressing_style' in self.s3_config: - s3_params['config'] = Config(s3={"addressing_style": self.addressing_style}) + config_kwargs['addressing_style'] = self.addressing_style + if config_kwargs: + s3_params['config'] = Config(**config_kwargs) + self.conn = boto3.client('s3', **s3_params) except Exception: logging.exception(f"Fail to connect at region {self.region} or endpoint {self.endpoint_url}")