I have a s3 bucket named 'Sample_Bucket' in which there is a folder called 'Sample_Folder'. I need to get only the names of all the files in the folder 'Sample_Folder'.
I am using the following code to do so -
import boto3
s3 = boto3.resource('s3', region_name='us-east-1', verify=False)
bucket = s3.Bucket('Sample_Bucket')
for files in bucket.objects.filter(Prefix='Sample_Folder):
print(files)
The variable files contain object variables which has the filename as key.
s3.ObjectSummary(bucket_name='Sample-Bucket', key='Sample_Folder/Sample_File.txt')
But I need only the filename. How do I extract that? Or is there any other way to do it?