Skip to content

Commit 45677bd

Browse files
feat(s3): support credential-scoped endpoint and OSS storage provider (#2019)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d423cc4 commit 45677bd

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

flow360/cloud/s3_utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from abc import ABCMeta, abstractmethod
99
from datetime import datetime
1010
from enum import Enum
11+
from typing import Optional
1112

1213
# pylint: disable=unused-import
1314
from pydantic.v1 import BaseModel, Field
@@ -115,6 +116,8 @@ class _UserCredential(BaseModel):
115116
secret_access_key: str = Field(alias="secretAccessKey")
116117
session_token: str = Field(alias="sessionToken")
117118
region: str
119+
endpoint: Optional[str] = None
120+
storage_provider: Optional[str] = Field(alias="storageProvider", default=None)
118121

119122

120123
class _S3STSToken(BaseModel):
@@ -149,7 +152,13 @@ def get_client(self):
149152

150153
# pylint: disable=no-member
151154
config_kwargs = {"max_pool_connections": MAX_POOL}
152-
if Env.current.s3_endpoint_url is not None:
155+
if (self.user_credential.storage_provider or "").upper() == "OSS":
156+
# OSS does not support aws integrity check
157+
config_kwargs["request_checksum_calculation"] = "when_required"
158+
config_kwargs["response_checksum_validation"] = "when_required"
159+
# OSS recommends virtual-hosted style addressing (http://bucket.host/key).
160+
config_kwargs["s3"] = {"addressing_style": "virtual"}
161+
elif Env.current.s3_endpoint_url is not None:
153162
# S3-compatible stores (s3proxy, MinIO) may not implement the
154163
# checksum headers that newer boto3 versions send by default.
155164
config_kwargs["request_checksum_calculation"] = "when_required"
@@ -175,6 +184,9 @@ def get_client(self):
175184
"config": config,
176185
}
177186

187+
if self.user_credential.endpoint is not None:
188+
kwargs["endpoint_url"] = self.user_credential.endpoint
189+
178190
if Env.current.s3_endpoint_url is not None:
179191
kwargs["endpoint_url"] = Env.current.s3_endpoint_url
180192

0 commit comments

Comments
 (0)