libushang пре 3 недеља
родитељ
комит
4a89822dd3
2 измењених фајлова са 12 додато и 10 уклоњено
  1. 6 6
      jobs/yst_job.py
  2. 6 4
      routers/api/yst/file.py

+ 6 - 6
jobs/yst_job.py

@@ -20,14 +20,14 @@ def daiban_proc():
             check_qyyjya_ok(db)
             check_yjylzj_ok(db)
 
-            db.query(YstQyjcxxEntity).update({"update_time": datetime.now()})
-            db.commit()
+            # db.query(YstQyjcxxEntity).update({"update_time": datetime.now()})
+            # db.commit()
 
-            db.query(YstQyyjyaEntity).update({"update_time": datetime.now()})
-            db.commit()
+            # db.query(YstQyyjyaEntity).update({"update_time": datetime.now()})
+            # db.commit()
             
-            db.query(YstYjylzjEntity).update({"update_time": datetime.now()})
-            db.commit()
+            # db.query(YstYjylzjEntity).update({"update_time": datetime.now()})
+            # db.commit()
             
     except Exception as e:
         traceback.print_exc()

+ 6 - 4
routers/api/yst/file.py

@@ -167,17 +167,19 @@ async def show(
             image_filepath = os.path.join(settings.UPLOAD_IMAGE_PATH, "blank.png")
             return FileResponse(image_filepath)
         
-        print('file show ==========>', row.file_type, image_filepath)
+        suffix = os.path.splitext(file_name)[-1]
+        print('file show ==========>', row.file_type, image_filepath, suffix)
         if thumb != '':
             print('thumb !!!')
+            Image.MAX_IMAGE_PIXELS = None
             image = Image.open(image_filepath)
-            w = image.width
-            h = image.height
             buf = BytesIO()
-            image.thumbnail((256, h*256/w))
+            image.thumbnail((100, 100))
             image.save(buf, 'png')
             img_data = buf.getvalue()
             return StreamingResponse(BytesIO(img_data), media_type="image/png")
         else:
             return FileResponse(image_filepath)
+    else:
+        logger.error("file not exists {}", file_name)