|
|
|
@ -4,6 +4,7 @@ from collections.abc import Generator
|
|
|
|
import boto3 # type: ignore
|
|
|
|
import boto3 # type: ignore
|
|
|
|
from botocore.client import Config # type: ignore
|
|
|
|
from botocore.client import Config # type: ignore
|
|
|
|
from botocore.exceptions import ClientError # type: ignore
|
|
|
|
from botocore.exceptions import ClientError # type: ignore
|
|
|
|
|
|
|
|
import botocore
|
|
|
|
|
|
|
|
|
|
|
|
from configs import dify_config
|
|
|
|
from configs import dify_config
|
|
|
|
from extensions.storage.base_storage import BaseStorage
|
|
|
|
from extensions.storage.base_storage import BaseStorage
|
|
|
|
@ -26,13 +27,21 @@ class AwsS3Storage(BaseStorage):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.info("Using ak and sk for S3")
|
|
|
|
logger.info("Using ak and sk for S3")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if dify_config.S3_SIGNATURE_VERSION == 'unsigned':
|
|
|
|
|
|
|
|
s_version = botocore.UNSIGNED
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
s_version = dify_config.S3_SIGNATURE_VERSION
|
|
|
|
|
|
|
|
|
|
|
|
self.client = boto3.client(
|
|
|
|
self.client = boto3.client(
|
|
|
|
"s3",
|
|
|
|
"s3",
|
|
|
|
aws_secret_access_key=dify_config.S3_SECRET_KEY,
|
|
|
|
aws_secret_access_key=dify_config.S3_SECRET_KEY,
|
|
|
|
aws_access_key_id=dify_config.S3_ACCESS_KEY,
|
|
|
|
aws_access_key_id=dify_config.S3_ACCESS_KEY,
|
|
|
|
endpoint_url=dify_config.S3_ENDPOINT,
|
|
|
|
endpoint_url=dify_config.S3_ENDPOINT,
|
|
|
|
region_name=dify_config.S3_REGION,
|
|
|
|
region_name=dify_config.S3_REGION,
|
|
|
|
config=Config(s3={"addressing_style": dify_config.S3_ADDRESS_STYLE}),
|
|
|
|
config=Config(
|
|
|
|
|
|
|
|
s3={"addressing_style": dify_config.S3_ADDRESS_STYLE},
|
|
|
|
|
|
|
|
signature_version=s_version
|
|
|
|
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
# create bucket
|
|
|
|
# create bucket
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|