I am trying to count the total no: of files uploaded to Azure Functions (Python). Tried uploading multiple files via postman but the AZ Func always reads only the first file and count is always 1. Why is that? Please help.
for input_file in req.files.values():
filename = input_file.filename
logging.info('Filename: %s' % filename)
fileDict = (req.files.to_dict(flat=False))
for eachItem in list(fileDict.values()):
# total no: of files uploaded (len(eachItem))
for file in eachItem:
print(file.filename)
content = file.stream.read()
print(len(content))
Since Azure Functions (Python) was using Flask framework, I had dig into Flask documentation which led me to Werkzeug Data Structures, then to ImmutableDict which was causing the problem. The solution is to convert the ImmutableDict to dict by using to_dict.