Be more specific about where to write the outfile

This commit is contained in:
niten 2023-01-10 16:07:55 -08:00
parent 50a22caea1
commit 9dd9e38eab
1 changed files with 8 additions and 6 deletions

View File

@ -125,15 +125,17 @@ def analyze_image(request: Request, image: UploadFile):
chunk = image.file.read(buffer_size)
print("save complete")
print("analyzing image")
result = detector.detect_objects(infile, file_hash.hexdigest() + ".png")
result = detector.detect_objects(
infile,
str(outgoing_dir / (file_hash.hexdigest() + ".png")))
print("image analyzed")
remove(infile)
return result_to_dict(result, base_url)
@app.get("/analyzed_images/${image_name}", response_class=FileResponse)
def get_analyzed_image(image_name):
filename = str(outgoing_dir / image_name)
@app.get("/analyzed_images/{image_name}", response_class=FileResponse)
def get_analyzed_image(image_name: str):
filename = outgoing_dir / image_name
if path.isfile(filename):
return filename
return str(filename)
else:
raise HTTPException(status_code=404, detail="file not found: " + filename)
raise HTTPException(status_code=404, detail="file not found: " + str(filename))