feat 新增接口描述 docs页面 ,新增S3 图片get upload 操作,整理代码
fix
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
"""
|
||||
import io
|
||||
import logging
|
||||
import time
|
||||
|
||||
# import boto3
|
||||
import cv2
|
||||
@@ -18,8 +17,8 @@ from PIL import Image
|
||||
from minio import Minio
|
||||
|
||||
from app.core.config import *
|
||||
from app.service.utils.decorator import RunTime
|
||||
from app.service.utils.generate_uuid import generate_uuid
|
||||
from app.service.utils.oss_client import oss_upload_image
|
||||
|
||||
minio_client = Minio(
|
||||
MINIO_URL,
|
||||
@@ -27,6 +26,7 @@ minio_client = Minio(
|
||||
secret_key=MINIO_SECRET,
|
||||
secure=MINIO_SECURE)
|
||||
|
||||
|
||||
# s3 = boto3.client(
|
||||
# 's3',
|
||||
# aws_access_key_id=S3_ACCESS_KEY,
|
||||
@@ -134,8 +134,14 @@ def synthesis(data, size):
|
||||
image_data = io.BytesIO()
|
||||
result_image.save(image_data, format='PNG')
|
||||
image_data.seek(0)
|
||||
|
||||
# oss upload
|
||||
image_bytes = image_data.read()
|
||||
return f"aida-results/{minio_client.put_object('aida-results', f'result_{generate_uuid()}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}"
|
||||
bucket_name = 'aida-results'
|
||||
object_name = f'result_{generate_uuid()}.png'
|
||||
req = oss_upload_image(bucket=bucket_name, object_name=object_name, image_bytes=image_bytes)
|
||||
return f"{bucket_name}/{object_name}"
|
||||
# return f"aida-results/{minio_client.put_object('aida-results', f'result_{generate_uuid()}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}"
|
||||
|
||||
# object_name = f'result_{generate_uuid()}.png'
|
||||
# response = s3.put_object(Bucket="aida-results", Key=object_name, Body=data, ContentType='image/png')
|
||||
|
||||
Reference in New Issue
Block a user