From 10753da02cd60e3f0a59afe770627951f7618397 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Tue, 9 Jul 2024 00:29:39 +0800 Subject: [PATCH] yh --- Application/Admin/Model/PictureModel.class.php | 10 +++++----- Application/Home/Model/PictureModel.class.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Model/PictureModel.class.php b/Application/Admin/Model/PictureModel.class.php index 69e0dd3d0..8960ae49c 100644 --- a/Application/Admin/Model/PictureModel.class.php +++ b/Application/Admin/Model/PictureModel.class.php @@ -15,6 +15,7 @@ use Admin\Event\QiNiuEvent; use Think\Model; use Think\Upload; use Base\Service\OssService; +use Base\Tool\Storage; /** * 图片模型 @@ -70,15 +71,14 @@ class PictureModel extends Model{ $this->where(['id'=>$value['id']])->save($data); } } - if (C('OSS_STATUS')) { + if (C('STORAGE_TYPE')) { $path = explode('/', $value['path']); $saveFileName = 'icon/' . $path[4]; $localFilePath = '.' . $value['path']; - $ossService = new OssService(); - $result = $ossService->upload($localFilePath, $saveFileName); + $result = Storage::upload($localFilePath, $saveFileName); if ($result['status']) { - $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); - $coo = $this->where(['id' => $value['id']])->save($dataUrl); + $dataUrl['oss_url'] = $result['data']['url']; + $this->where(['id' => $value['id']])->save($dataUrl); } else { $this->error = $result['message']; return false; diff --git a/Application/Home/Model/PictureModel.class.php b/Application/Home/Model/PictureModel.class.php index bdfdc8010..28c8548df 100644 --- a/Application/Home/Model/PictureModel.class.php +++ b/Application/Home/Model/PictureModel.class.php @@ -11,6 +11,7 @@ namespace Home\Model; use Think\Model; use Think\Upload; use Base\Service\OssService; +use Base\Tool\Storage; /** * 图片模型 @@ -56,15 +57,14 @@ class PictureModel extends Model{ unset($info[$key]); } } - if (C('OSS_STATUS')) { + if (C('STORAGE_TYPE')) { $path = explode('/', $value['path']); $saveFileName = 'icon/' . $path[4]; $localFilePath = '.' . $value['path']; - $ossService = new OssService(); - $ossService->upload($localFilePath, $saveFileName); + $result = Storage::upload($localFilePath, $saveFileName); if ($result['status']) { - $dataUrl['oss_url'] = $ossService->getUrl($saveFileName); - $coo = $this->where(['id' => $value['id']])->save($dataUrl); + $dataUrl['oss_url'] = $result['data']['url']; + $this->where(['id' => $value['id']])->save($dataUrl); } else { $this->error = $result['message']; return false;