Function
calculate_file_hash
(file: UploadFile, chunk_size=1024 * 1024)
Source from the content-addressed store, hash-verified
| 114 | |
| 115 | |
| 116 | async 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 | |
| 128 | ip_limit = { |
Callers
nothing calls this directly
Tested by
no test coverage detected