1👍
✅
When you read the file content (for calculating md5 hash) you need to move the file object’s position to the beginning (0th byte) using file.seek
:
md5hash = md5()
for chunk in f.chunks():
md5hash.update(chunk)
file_hash = md5hash.hexdigest()
f.seek(0) #<-- add this line
Source:stackexchange.com