in rekognition-pipeline/lambda/helper/python/helper.py [0:0]
def getFileNames(bucketName, prefix, maxPages, allowedFileTypes, awsRegion=None):
files = []
currentPage = 1
hasMoreContent = True
continuationToken = None
s3client = AwsHelper().getClient('s3', awsRegion)
while(hasMoreContent and currentPage <= maxPages):
if(continuationToken):
listObjectsResponse = s3client.list_objects_v2(
Bucket=bucketName,
Prefix=prefix,
ContinuationToken=continuationToken)
else:
listObjectsResponse = s3client.list_objects_v2(
Bucket=bucketName,
Prefix=prefix)
if(listObjectsResponse['IsTruncated']):
continuationToken = listObjectsResponse['NextContinuationToken']
else:
hasMoreContent = False
for item in listObjectsResponse['Contents']:
itemName = item['Key']
itemExt = FileHelper.getFileExtenstion(itemName)
itemExtLower = itemExt.lower()
if(itemExtLower in allowedFileTypes):
files.append(itemName)
return files