Give `UploadFile` another try
This commit is contained in:
parent
8254b94a88
commit
1e3012bf7f
|
@ -111,14 +111,18 @@ def result_to_dict(res, base_url):
|
|||
# return result_to_dict(result, base_url)
|
||||
|
||||
@app.post("/images")
|
||||
def analyze_image(request: Request, image: bytes = File()):
|
||||
def analyze_image(request: Request, image: UploadFile):
|
||||
print("Initiating file receipt, url: " + str(request.url))
|
||||
base_url = re.sub(r'\/images\/?$', '/analyzed_images/', str(request.url))
|
||||
infile = open(incoming_dir / file.filename)
|
||||
infile = open(incoming_dir / image.filename)
|
||||
file_hash = hashlib.sha256()
|
||||
file_hash.update(image)
|
||||
with open(infile, "w") as f:
|
||||
f.write(image)
|
||||
with open(infile, "wb") as f:
|
||||
chunk = image.read(buffer_size)
|
||||
while chunk:
|
||||
print ("writing " + buffer_size + " bytes")
|
||||
f.write(chunk)
|
||||
chunk = image.read(buffer_size)
|
||||
print("save complete")
|
||||
print("analyzing image")
|
||||
result = detector.detect_objects(infile, file_hash.hexdigest() + ".png")
|
||||
|
|
Loading…
Reference in New Issue