animeic 2 years ago
parent
commit
6088c61690
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/main.py

+ 4 - 0
src/main.py

@@ -83,6 +83,7 @@ async def upload_images(
     url: str = None
 ):
     try:
+        img_path = ""
         if image is not None:
             content = await image.read()
             img_path = os.path.join(UPLOAD_PATH, image.filename)
@@ -95,6 +96,9 @@ async def upload_images(
             return {'status': False, 'msg': 'Image and url are required'}, 400
         vector_id = do_upload(table_name,partition_name,im_hash, product_id, img_path, MODEL, MILVUS_CLI)
         LOGGER.info(f"Successfully uploaded data, vector id: {vector_id}")
+        # 删除 对应图片缓存文件
+        if len(img_path) > 0:
+            os.remove(img_path)
         return {'id':vector_id[0]}
     except Exception as e:
         LOGGER.error(e)