feat 新增接口描述 docs页面 ,新增S3 图片get upload 操作,整理代码
fix
This commit is contained in:
@@ -10,30 +10,13 @@
|
||||
import io
|
||||
import logging
|
||||
|
||||
# import boto3
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from minio import Minio
|
||||
|
||||
from app.core.config import *
|
||||
from app.service.utils.generate_uuid import generate_uuid
|
||||
from app.service.utils.oss_client import oss_upload_image
|
||||
|
||||
minio_client = Minio(
|
||||
MINIO_URL,
|
||||
access_key=MINIO_ACCESS,
|
||||
secret_key=MINIO_SECRET,
|
||||
secure=MINIO_SECURE)
|
||||
|
||||
|
||||
# s3 = boto3.client(
|
||||
# 's3',
|
||||
# aws_access_key_id=S3_ACCESS_KEY,
|
||||
# aws_secret_access_key=S3_AWS_SECRET_ACCESS_KEY,
|
||||
# region_name=S3_REGION_NAME
|
||||
# )
|
||||
|
||||
|
||||
def positioning(all_mask_shape, mask_shape, offset):
|
||||
all_start = 0
|
||||
@@ -176,4 +159,9 @@ def synthesis_single(front_image, back_image):
|
||||
result_image.save(image_data, format='PNG')
|
||||
image_data.seek(0)
|
||||
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}"
|
||||
# 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}"
|
||||
# oss upload
|
||||
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}"
|
||||
|
||||
Reference in New Issue
Block a user