Use s3 configuration from settings module (#4167)

### What problem does this PR solve?

Fix the issue when retrieving AWS credentials from the S3 configuration
from the settings module instead of getting from the environment
variables.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
Kenny Dizi 2024-12-23 09:22:45 +07:00 committed by GitHub
parent cb45431412
commit f13f503952
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,15 +6,17 @@ from botocore.client import Config
import time import time
from io import BytesIO from io import BytesIO
from rag.utils import singleton from rag.utils import singleton
from rag import settings
@singleton @singleton
class RAGFlowS3(object): class RAGFlowS3(object):
def __init__(self): def __init__(self):
self.conn = None self.conn = None
self.endpoint = os.getenv('ENDPOINT', None) self.s3_config = settings.S3
self.access_key = os.getenv('ACCESS_KEY', None) self.endpoint = self.s3_config.get('endpoint', None)
self.secret_key = os.getenv('SECRET_KEY', None) self.access_key = self.s3_config.get('access_key', None)
self.region = os.getenv('REGION', None) self.secret_key = self.s3_config.get('secret_key', None)
self.region = self.s3_config.get('region', None)
self.__open__() self.__open__()
def __open__(self): def __open__(self):