6464from servicelib .bytes_iters ._models import DataSize
6565from servicelib .file_utils import remove_directory
6666from servicelib .progress_bar import ProgressBarData
67+ from servicelib .s3_utils import FileLikeBytesIterReader
6768from servicelib .utils import limited_as_completed , limited_gather
6869from settings_library .s3 import S3Settings
6970from types_aiobotocore_s3 import S3Client
@@ -1417,7 +1418,7 @@ async def test_read_object_file_stream(
14171418 await assert_same_file_content (with_uploaded_file_on_s3 .local_path , tmp_file_name )
14181419
14191420
1420- async def test_upload_object_from_file_stream (
1421+ async def test_upload_object_from_file_like (
14211422 mocked_s3_server_envs : EnvVarsDict ,
14221423 with_uploaded_file_on_s3 : UploadedFile ,
14231424 simcore_s3_api : SimcoreS3API ,
@@ -1429,10 +1430,14 @@ async def test_upload_object_from_file_stream(
14291430 )
14301431 assert isinstance (bytes_streamer .data_size , DataSize )
14311432
1432- await simcore_s3_api .upload_object_from_bytes_iter (
1433- with_s3_bucket , object_key , bytes_streamer .with_progress_bytes_iter (AsyncMock ())
1433+ await simcore_s3_api .upload_object_from_file_like (
1434+ with_s3_bucket ,
1435+ object_key ,
1436+ FileLikeBytesIterReader (bytes_streamer .with_progress_bytes_iter (AsyncMock ())),
14341437 )
14351438
1439+ # TODO: also add a test uploading form a file instead of S3 since it's possible, open it with aiofiles
1440+
14361441 await simcore_s3_api .delete_object (bucket = with_s3_bucket , object_key = object_key )
14371442
14381443
@@ -1589,13 +1594,15 @@ async def test_workflow_compress_s3_objects_and_local_files_in_a_single_archive_
15891594 progress_report_cb = mocked_progress_bar_cb ,
15901595 description = "root_bar" ,
15911596 ) as progress_bar :
1592- await simcore_s3_api .upload_object_from_bytes_iter (
1597+ await simcore_s3_api .upload_object_from_file_like (
15931598 with_s3_bucket ,
15941599 archive_s3_object_key ,
1595- get_zip_bytes_iter (
1596- archive_entries ,
1597- progress_bar = progress_bar ,
1598- chunk_size = MULTIPART_COPY_THRESHOLD ,
1600+ FileLikeBytesIterReader (
1601+ get_zip_bytes_iter (
1602+ archive_entries ,
1603+ progress_bar = progress_bar ,
1604+ chunk_size = MULTIPART_COPY_THRESHOLD ,
1605+ )
15991606 ),
16001607 )
16011608
0 commit comments