@@ -38,19 +38,19 @@ def __init__(self, creds_getter: Callable[[], AWSCredentials], enable_additional
3838 self ._upload_args = dict (ChecksumAlgorithm = 'SHA256' ) if enable_additional_checksum else dict ()
3939 self ._download_args = dict (ChecksumMode = 'ENABLED' ) if enable_additional_checksum else dict ()
4040
41- def upload_file (self , local_path : Path , bucket : str , key : str ):
42- file_size = local_path .stat ().st_size
43- file_name = local_path .name
41+ def upload_file (self , file_path : Path , bucket : str , key : str ):
42+ file_size = file_path .stat ().st_size
43+ file_name = file_path .name
4444
4545 with tqdm (total = file_size ,
4646 desc = f'Uploading file { file_name } ({ convert_size (file_size )} )' ,
4747 bar_format = "{desc} | {percentage:.1f}%|{bar:25} | {rate_fmt}" ,
4848 unit = 'B' , unit_scale = True ,
4949 unit_divisor = 1024 ) as progress :
50- absolute_path = str ( local_path . absolute ())
51- self ._client .upload_file ( absolute_path , bucket , key ,
52- Callback = ProgressPercentage (progress ),
53- ExtraArgs = self ._upload_args )
50+ with file_path . open ( 'rb' ) as file :
51+ self ._client .upload_fileobj ( file , bucket , key ,
52+ Callback = ProgressPercentage (progress ),
53+ ExtraArgs = self ._upload_args )
5454
5555 def download_file (self , local_path : Path , bucket : str , key : str ):
5656 file_size = self .get_file_stats (bucket , key )['ContentLength' ]
0 commit comments