- def list_files(bucket):
- """
- Function to list files in a given S3 bucket
- """
- s3 = boto3.client('s3')
- contents = []
- try:
- for item in s3.list_objects(Bucket=bucket)['Contents']:
- print(item)
- contents.append(item)
- except Exception as e:
- pass
- return contents
|