88from abc import ABCMeta , abstractmethod
99from datetime import datetime
1010from enum import Enum
11+ from typing import Optional
1112
1213# pylint: disable=unused-import
1314from 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
120123class _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