I have an AWS Lambda snippet like this. The purpose is to generate the checksum of the file of the given URL. The URL is from an S3 bucket. The checksum generating and printing, that is fine. But every time I execute the lambda, a NEW checksum is generated, that is the issue. As there is no change to the file, I am EXPECTING the same checksum value every time.
import hashlib
import requests
def checksum(url):
BUF_SIZE = 65536 # lets read stuff in 64kb chunks!
m = hashlib.sha256()
r = requests.get(url)
for data in r.iter_content(BUF_SIZE):
m.update(data)
return m.hexdigest()
def lambda_handler(event, context):
url = "https://xxx-xxx-xxxxx-us-east-1-dev.s3.amazonaws.com/HDBAPA104APAL_Barbapapa_xxx_servicing_25_clip_submission_5dot1.mov"
print(f"{checksum(url)}")