MCPcopy Create free account
hub / github.com/vastsa/FileCodeBox / calculate_file_hash

Function calculate_file_hash

apps/base/utils.py:116–125  ·  view source on GitHub ↗
(file: UploadFile, chunk_size=1024 * 1024)

Source from the content-addressed store, hash-verified

114
115
116async def calculate_file_hash(file: UploadFile, chunk_size=1024 * 1024) -> str:
117 sha = hashlib.sha256()
118 await file.seek(0)
119 while True:
120 chunk = await file.read(chunk_size)
121 if not chunk:
122 break
123 sha.update(chunk)
124 await file.seek(0)
125 return sha.hexdigest()
126
127
128ip_limit = {

Callers

nothing calls this directly

Calls 1

readMethod · 0.80

Tested by

no test coverage detected