@@ -26,7 +26,9 @@ def __build_bucket_base_url(self):
2626 else :
2727 return f"https://s3.amazonaws.com/{ self ._bucket_name } "
2828
29- def put_images (self , images , submission_id , composite_id , customer_id , space_id ):
29+ def put_images (
30+ self , image_paths , submission_id , composite_id , customer_id , space_id
31+ ):
3032 s3_uris = []
3133
3234 key_prefix = self .__get_key_prefix (
@@ -36,14 +38,14 @@ def put_images(self, images, submission_id, composite_id, customer_id, space_id)
3638 with tqdm .tqdm (
3739 desc = f"[{ submission_id } ] Upload images to S3" ,
3840 unit = " image" ,
39- total = len (images ),
41+ total = len (image_paths ),
4042 ) as progress_bar :
4143 with ThreadPoolExecutor (max_workers = self ._upload_threads ) as executor :
4244 # It's critical that the list of S3 URI's returned by this method is in the
4345 # same order as the list of images provided to it. '.map(...)' gives us that,
4446 # whilst '.submit(...)' does not.
4547 for s3_uri in executor .map (
46- self .__put_image , repeat (key_prefix ), images
48+ self .__put_image , repeat (key_prefix ), image_paths
4749 ):
4850 s3_uris .append (s3_uri )
4951 progress_bar .update (1 )
@@ -52,8 +54,8 @@ def put_images(self, images, submission_id, composite_id, customer_id, space_id)
5254 def __get_key_prefix (self , submission_id , composite_id , customer , space ):
5355 return f"{ self ._object_key_prefix } /{ customer } /{ space } /{ composite_id or submission_id } "
5456
55- def __put_image (self , key_prefix , image ):
56- object_key = f"{ key_prefix } /{ os .path .basename (image . filename )} "
57- with open (image . filename , "rb" ) as file :
57+ def __put_image (self , key_prefix , image_path ):
58+ object_key = f"{ key_prefix } /{ os .path .basename (image_path )} "
59+ with open (image_path , "rb" ) as file :
5860 self ._client .put_object (Bucket = self ._bucket_name , Key = object_key , Body = file )
5961 return f"{ self ._bucket_base_url } /{ object_key } "
0 commit comments