File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -77,3 +77,22 @@ def check_if_file_key_exists_in_bucket(self, file_key):
7777 return False
7878
7979 return True
80+
81+ def download_file (self , s3_object_name , destination_file ):
82+ """
83+ Download a file from an S3 bucket
84+
85+ :param s3_object_name: S3 object name to download from
86+ :type s3_object_name: str
87+ :param destination_file: Full path where the file should be downloaded
88+ :type destination_file: str
89+ """
90+
91+ s3_prefix = f"s3://{ self .bucket_name } /"
92+ s3_file_name = s3_object_name [len (s3_prefix ):] if s3_object_name .startswith (s3_prefix ) else s3_object_name
93+
94+ try :
95+ print (f"Downloading { s3_file_name } from { self .aws_endpoint_url } /{ self .bucket_name } to { destination_file } " )
96+ self .s3_bucket_obj .download_file (s3_file_name , destination_file )
97+ except ClientError as err :
98+ raise Exception (f"{ s3_object_name } download failure = { format (err )} " )
You can’t perform that action at this time.
0 commit comments