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