|
@@ -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)
|
|
|
|