Skip to content

Commit

Permalink
Revert "add: function to get s3 files metadata"
Browse files Browse the repository at this point in the history
This reverts commit e2d25cc.
  • Loading branch information
Camille Modeste committed Sep 13, 2023
1 parent e2d25cc commit fba4e98
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions pyro_risks/utils/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class S3Bucket:
aws_access_key_id='my_access_key_id',
aws_secret_key='my_secret_key'
)
NOTE: credentials should never be in the code.
To upload a file to the bucket, use:
Expand Down Expand Up @@ -133,28 +133,3 @@ def get_file_metadata(self, object_key):
obj = self.bucket.Object(object_key)
metadata = obj.metadata
return metadata

def get_files_metadata(self, pattern=None):
"""
Lists files in the S3 bucket with their size in GB and last modified dates.
Args:
pattern (str): The pattern to filter files by (optional).
Returns:
A dictionnary of file keys (paths), file sizes en GB and last modified dates in the bucket.
"""
files = []
for obj in self.bucket.objects.all():
if not pattern or pattern in obj.key:
file_name = obj.key
file_size = round(obj.size * 1.0 / 1024, 2)
file_last_modified = obj.last_modified
files.append(
{
"file_name": file_name,
"file_size": file_size,
"file_last_modified": file_last_modified,
}
)
return files

0 comments on commit fba4e98

Please sign in to comment.