fix: 修复file为空是报错的问题

This commit is contained in:
兰涛 2024-08-14 12:02:18 +08:00
parent f9e3624eff
commit fd8318b559

View File

@ -38,7 +38,7 @@ async def ocr_endpoint(
png_fix: bool = Form(False) png_fix: bool = Form(False)
): ):
try: try:
if file.size == 0 and image is None: if file and file.file._file is None and image is None:
return APIResponse(code=400, message="Either file or image must be provided") return APIResponse(code=400, message="Either file or image must be provided")
image_bytes = await decode_image(file or image) image_bytes = await decode_image(file or image)
@ -74,7 +74,7 @@ async def detection_endpoint(
image: Optional[str] = Form(None) image: Optional[str] = Form(None)
): ):
try: try:
if file.size == 0 and image is None: if file and file.file._file is None and image is None:
return APIResponse(code=400, message="Either file or image must be provided") return APIResponse(code=400, message="Either file or image must be provided")
image_bytes = await decode_image(file or image) image_bytes = await decode_image(file or image)