INNER CODE UNIT · Python
download_file
futo-org/android-keyboard · java/res-bundle/download-bundles.py:20
def download_file(url, dest_path):
headers = {}
response = requests.get(url, headers=headers, stream=True)
response.raise_for_status()
with open(dest_path, "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
def verify_sha256(filepath, expected_checksum):
sha256 = hashlib.sha256()
with open(filepath, "rb") as f:
for chunk in iter(lambda: f.read(8192), b""):
sha256.update(chunk)
return sha256.hexdigest() == expected_checksum
if __name__ == "__main__":