Преглед изворни кода

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 <zhanluxianshen@163.com>
tags/v0.20.0
湛露先生 пре 3 месеци
родитељ
комит
fd97ce3e5a
No account linked to committer's email address
1 измењених фајлова са 6 додато и 2 уклоњено
  1. 6
    2
      rag/utils/s3_conn.py

+ 6
- 2
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}")

Loading…
Откажи
Сачувај