From a940c7c021b8e552d455a431950612d8a9e6ef12 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 9 Sep 2022 15:17:37 +0800 Subject: [PATCH] cdn --- .env | 4 ++-- app/common.php | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.env b/.env index e6d65dd..92aca90 100644 --- a/.env +++ b/.env @@ -28,6 +28,6 @@ REGIONID=cn-hangzhou SIGNNAME=域展科技 TEMPLATECODE=SMS_176560077 OSS_BUCKET=hphb-storage -OSS_ENDPOINT=hphb-cdn.uzchain.tech -#OSS_ENDPOINT=oss-cn-beijing.aliyuncs.com +CDN_NAME=hphb-cdn.uzchain.tech +OSS_ENDPOINT=oss-cn-beijing.aliyuncs.com diff --git a/app/common.php b/app/common.php index 4288dc2..68c409f 100644 --- a/app/common.php +++ b/app/common.php @@ -236,7 +236,15 @@ if (! function_exists('aliyun')) { if (empty($info['info']['url'])) { return ['code' => 1, 'message' => "上传失败"]; } - return ['code' => 0, 'message' => "", 'url' => $info['info']['url']]; + return [ + 'code' => 0, + 'message' => "", + 'url' => str_replace( + env('ALIYUNSMS.OSS_BUCKET').'.'.env('ALIYUNSMS.OSS_ENDPOINT'), + env('ALIYUNSMS.CDN_NAME'), + $info['info']['url'] + ), + ]; } catch (OssException $e) { return ['code' => 1, 'message' => $e->getMessage()]; }