From 330084ea4a4675e74bceff7981100898300eeaf8 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Fri, 18 Aug 2023 21:07:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8E=A5=E5=8F=A3=E7=9A=84=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/v1/api.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/api/v1/api.py b/app/api/v1/api.py index 1b80bae..ea0f138 100644 --- a/app/api/v1/api.py +++ b/app/api/v1/api.py @@ -17,6 +17,7 @@ api = APIBlueprint('api', __name__) @api.post('/images') @api.doc(summary='上传图片', description='上传图片') @api.input(ImageIn, location='files') +@api.output(ImagePreSignUrlOut) @login_required def upload_image(files_data): f = files_data['image'] @@ -36,9 +37,16 @@ def upload_image(files_data): except Exception as e: raise UserInfoError(extra_data={'error_docs': str(e)}) - return {'msg': 'uploading image success'} + try: + presign_url = rpc.storage.get_presign_url(result['_id'], + 'bodyrecord', + bucket='bodyrecord') + except Exception as e: + raise ImageNotFound(extra_data={'error_docs': str(e)}) + + return {'image_presign_url': presign_url} else: - return {'msg': 'uploading image fail'} + raise ImageUploadError() @api.get('/images/presign_url')