I needed it because I needed it
# -*- coding: utf-8 -*-
import boto3
PUBLIC_S3_BUCKET_NAME_TEST = 'Bucket name'
def access_count():
count = 0
with open('file.txt', 'w') as f:
#Get a list of buckets
S3 = boto3.resource('s3')
S3BUCKET = S3.Bucket(PUBLIC_S3_BUCKET_NAME_TEST)
for obj in S3BUCKET.objects.all():
if 'Search name' in obj.key:
count += 1
print(count, obj.key, obj.last_modified, file=f)
print('total=' + str(count), file=f)
Recommended Posts