mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Feat: add addressing style config for S3-compatible storage (#11510)
### Type of change * [x] New Feature (non-breaking change which adds functionality) Add support for Virtual Hosted Style and Path Style URL addressing in S3_COMPATIBLE storage connector. Default to Virtual Hosted Style for better compatibility with COS and other S3-compatible services. - Add addressing_style field to credentials (virtual/path) - Update frontend form with selection dropdown - Add validation and tooltips for S3 Compatible endpoint URL <img width="703" height="875" alt="image" src="https://github.com/user-attachments/assets/af5ba7ca-f160-47fa-8ba1-32eace8f5fdf" /> <img width="1620" height="788" alt="image" src="https://github.com/user-attachments/assets/6012b5ce-8bcb-478e-a9cb-425f886d5046" /> --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
@ -90,7 +90,7 @@ class BlobStorageConnector(LoadConnector, PollConnector):
|
|||||||
elif self.bucket_type == BlobType.S3_COMPATIBLE:
|
elif self.bucket_type == BlobType.S3_COMPATIBLE:
|
||||||
if not all(
|
if not all(
|
||||||
credentials.get(key)
|
credentials.get(key)
|
||||||
for key in ["endpoint_url", "aws_access_key_id", "aws_secret_access_key"]
|
for key in ["endpoint_url", "aws_access_key_id", "aws_secret_access_key", "addressing_style"]
|
||||||
):
|
):
|
||||||
raise ConnectorMissingCredentialError("S3 Compatible Storage")
|
raise ConnectorMissingCredentialError("S3 Compatible Storage")
|
||||||
|
|
||||||
|
|||||||
@ -312,11 +312,14 @@ def create_s3_client(bucket_type: BlobType, credentials: dict[str, Any], europea
|
|||||||
region_name=credentials["region"],
|
region_name=credentials["region"],
|
||||||
)
|
)
|
||||||
elif bucket_type == BlobType.S3_COMPATIBLE:
|
elif bucket_type == BlobType.S3_COMPATIBLE:
|
||||||
|
addressing_style = credentials.get("addressing_style", "virtual")
|
||||||
|
|
||||||
return boto3.client(
|
return boto3.client(
|
||||||
"s3",
|
"s3",
|
||||||
endpoint_url=credentials["endpoint_url"],
|
endpoint_url=credentials["endpoint_url"],
|
||||||
aws_access_key_id=credentials["aws_access_key_id"],
|
aws_access_key_id=credentials["aws_access_key_id"],
|
||||||
aws_secret_access_key=credentials["aws_secret_access_key"],
|
aws_secret_access_key=credentials["aws_secret_access_key"],
|
||||||
|
config=Config(s3={'addressing_style': addressing_style}),
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -715,6 +715,8 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
|
|||||||
Example: general/v2/`,
|
Example: general/v2/`,
|
||||||
S3CompatibleEndpointUrlTip: `Required for S3 compatible Storage Box. Specify the S3-compatible endpoint URL.
|
S3CompatibleEndpointUrlTip: `Required for S3 compatible Storage Box. Specify the S3-compatible endpoint URL.
|
||||||
Example: https://fsn1.your-objectstorage.com`,
|
Example: https://fsn1.your-objectstorage.com`,
|
||||||
|
S3CompatibleAddressingStyleTip: `Required for S3 compatible Storage Box. Specify the S3-compatible addressing style.
|
||||||
|
Example: Virtual Hosted Style`,
|
||||||
addDataSourceModalTital: 'Create your {{name}} connector',
|
addDataSourceModalTital: 'Create your {{name}} connector',
|
||||||
deleteSourceModalTitle: 'Delete data source',
|
deleteSourceModalTitle: 'Delete data source',
|
||||||
deleteSourceModalContent: `
|
deleteSourceModalContent: `
|
||||||
|
|||||||
@ -715,6 +715,8 @@ export default {
|
|||||||
Пример: general/v2/`,
|
Пример: general/v2/`,
|
||||||
S3CompatibleEndpointUrlTip: `Требуется для S3 совместимого Storage Box. Укажите URL конечной точки, совместимой с S3.
|
S3CompatibleEndpointUrlTip: `Требуется для S3 совместимого Storage Box. Укажите URL конечной точки, совместимой с S3.
|
||||||
Пример: https://fsn1.your-objectstorage.com`,
|
Пример: https://fsn1.your-objectstorage.com`,
|
||||||
|
S3CompatibleAddressingStyleTip: `Требуется для S3 совместимого Storage Box. Укажите стиль адресации, совместимый с S3.
|
||||||
|
Пример: Virtual Hosted Style`,
|
||||||
addDataSourceModalTital: 'Создайте ваш коннектор {{name}}',
|
addDataSourceModalTital: 'Создайте ваш коннектор {{name}}',
|
||||||
deleteSourceModalTitle: 'Удалить источник данных',
|
deleteSourceModalTitle: 'Удалить источник данных',
|
||||||
deleteSourceModalContent: `
|
deleteSourceModalContent: `
|
||||||
|
|||||||
@ -121,6 +121,21 @@ export const DataSourceFormFields = {
|
|||||||
],
|
],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Addressing Style',
|
||||||
|
name: 'config.credentials.addressing_style',
|
||||||
|
type: FormFieldType.Select,
|
||||||
|
options: [
|
||||||
|
{ label: 'Virtual Hosted Style', value: 'virtual' },
|
||||||
|
{ label: 'Path Style', value: 'path' },
|
||||||
|
],
|
||||||
|
required: false,
|
||||||
|
placeholder: 'Virtual Hosted Style',
|
||||||
|
tooltip: t('setting.S3CompatibleAddressingStyleTip'),
|
||||||
|
shouldRender: (formValues: any) => {
|
||||||
|
return formValues?.config?.bucket_type === 's3_compatible';
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Endpoint URL',
|
label: 'Endpoint URL',
|
||||||
name: 'config.credentials.endpoint_url',
|
name: 'config.credentials.endpoint_url',
|
||||||
@ -444,6 +459,7 @@ export const DataSourceFormDefaultValues = {
|
|||||||
aws_access_key_id: '',
|
aws_access_key_id: '',
|
||||||
aws_secret_access_key: '',
|
aws_secret_access_key: '',
|
||||||
endpoint_url: '',
|
endpoint_url: '',
|
||||||
|
addressing_style: 'virtual',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user