24 lines
555 B
Python
24 lines
555 B
Python
import hashlib
|
|
import re
|
|
import config
|
|
from minio import Minio
|
|
|
|
|
|
from fastapi import UploadFile
|
|
|
|
|
|
safeName = re.compile(r"[^\w\d\.-]")
|
|
|
|
# If this gets too out of hand, put an async breakpoint to allow other things to be handled while the hash occurs
|
|
async def SHA256(f: UploadFile) -> str:
|
|
sha = hashlib.sha256()
|
|
while data := await f.read(65535):
|
|
sha.update(data)
|
|
await f.seek(0)
|
|
return sha.hexdigest()
|
|
|
|
minioClient = Minio(
|
|
config.MINIO_ADDR,
|
|
access_key=config.MINIO_ACCESS_KEY,
|
|
secret_key=config.MINIO_SECRET_KEY,
|
|
)
|