in app/lambda/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 doc in listObjectsResponse['Contents']:
docName = doc['Key']
docExt = FileHelper.getFileExtenstion(docName)
docExtLower = docExt.lower()
if(docExtLower in allowedFileTypes):
files.append(docName)
return files