Open file in binary mode

This commit is contained in:
niten 2023-01-10 14:10:40 -08:00
parent 0915ec019b
commit c903c73270
1 changed files with 1 additions and 1 deletions

View File

@ -116,7 +116,7 @@ def analyze_image(request: Request, image: UploadFile):
base_url = re.sub(r'\/images\/?$', '/analyzed_images/', str(request.url))
infile = incoming_dir / image.filename
file_hash = hashlib.sha256()
with open(infile, "w") as f:
with open(infile, "wb") as f:
chunk = image.file.read(buffer_size)
while chunk:
file_hash.update(chunk)