1313from boto3 .s3 .transfer import TransferConfig
1414from botocore import exceptions as botocore_exc
1515from botocore .client import Config
16- from common_library .pydantic_networks_extension import AnyUrlLegacy
1716from models_library .api_schemas_storage import ETag , S3BucketName , UploadedPart
1817from models_library .basic_types import SHA256Str
1918from pydantic import AnyUrl , ByteSize , TypeAdapter
@@ -255,7 +254,7 @@ async def create_single_presigned_download_link(
255254 bucket : S3BucketName ,
256255 object_key : S3ObjectKey ,
257256 expiration_secs : int ,
258- ) -> str :
257+ ) -> AnyUrl :
259258 # NOTE: ensure the bucket/object exists, this will raise if not
260259 await self ._client .head_bucket (Bucket = bucket )
261260 await self ._client .head_object (Bucket = bucket , Key = object_key )
@@ -264,20 +263,20 @@ async def create_single_presigned_download_link(
264263 Params = {"Bucket" : bucket , "Key" : object_key },
265264 ExpiresIn = expiration_secs ,
266265 )
267- return f" { TypeAdapter (AnyUrlLegacy ).validate_python (generated_link )} "
266+ return TypeAdapter (AnyUrl ).validate_python (generated_link )
268267
269268 @s3_exception_handler (_logger )
270269 async def create_single_presigned_upload_link (
271270 self , * , bucket : S3BucketName , object_key : S3ObjectKey , expiration_secs : int
272- ) -> str :
271+ ) -> AnyUrl :
273272 # NOTE: ensure the bucket/object exists, this will raise if not
274273 await self ._client .head_bucket (Bucket = bucket )
275274 generated_link = await self ._client .generate_presigned_url (
276275 "put_object" ,
277276 Params = {"Bucket" : bucket , "Key" : object_key },
278277 ExpiresIn = expiration_secs ,
279278 )
280- return f" { TypeAdapter (AnyUrlLegacy ).validate_python (generated_link )} "
279+ return TypeAdapter (AnyUrl ).validate_python (generated_link )
281280
282281 @s3_exception_handler (_logger )
283282 async def create_multipart_upload_links (
@@ -474,6 +473,6 @@ def is_multipart(file_size: ByteSize) -> bool:
474473
475474 @staticmethod
476475 def compute_s3_url (* , bucket : S3BucketName , object_key : S3ObjectKey ) -> AnyUrl :
477- return TypeAdapter (AnyUrlLegacy ).validate_python (
476+ return TypeAdapter (AnyUrl ).validate_python (
478477 f"s3://{ bucket } /{ urllib .parse .quote (object_key )} "
479478 )
0 commit comments