feat : ali
This commit is contained in:
@@ -10,13 +10,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Common;
|
||||
|
||||
use AlibabaCloud\SDK\Sts\V20150401\Sts;
|
||||
use App\Cache\Redis\Common\CommonRedisKey;
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Exception\AdminException;
|
||||
use App\Lib\AdminReturn;
|
||||
use App\Lib\Log;
|
||||
use App\Service\ServiceTrait\Common\AliStsTrait;
|
||||
use App\Model\OssObject;
|
||||
use Exception;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
@@ -28,7 +27,6 @@ use function Hyperf\Config\config;
|
||||
|
||||
class OssCallbackService
|
||||
{
|
||||
use AliStsTrait;
|
||||
|
||||
/**
|
||||
* 请求对象
|
||||
@@ -116,7 +114,7 @@ class OssCallbackService
|
||||
$this->ossClient = new OssClient(
|
||||
config('ali.access_key_id'),
|
||||
config('ali.access_key_secret'),
|
||||
config('oss.sts_endpoint')
|
||||
config('ali.intranet_endpoint')
|
||||
);
|
||||
|
||||
$this->bucket = config('ali.bucket');
|
||||
@@ -167,7 +165,8 @@ class OssCallbackService
|
||||
|
||||
return $this->adminReturn->success('上传成功',[
|
||||
'id' => $this->newId,
|
||||
'url' => config('ali.oss_url') . $this->newObjectPath, 'old_file_name' => $this->fileName
|
||||
'url' => config('ali.oss_url') . $this->newObjectPath,
|
||||
'old_file_name' => $this->fileName
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -277,23 +276,23 @@ class OssCallbackService
|
||||
break;
|
||||
}
|
||||
|
||||
// $ossObjectModel = new OssObject();
|
||||
//
|
||||
// $ossObjectModel->url = $this->newObjectPath;
|
||||
//// $ossObjectModel->url = urldecode($this->data['object']);
|
||||
// $ossObjectModel->width = $this->data['imageInfo_width'] ?? 0;
|
||||
// $ossObjectModel->height = $this->data['imageInfo_height'] ?? 0;
|
||||
// $ossObjectModel->audio_second = $this->data['audio_second'] ?? 0;
|
||||
// $ossObjectModel->video_duration = $this->data['video_duration'] ?? 0;
|
||||
// $ossObjectModel->size = $this->data['size'] ?? 0;
|
||||
//
|
||||
// $ossObjectModel->type = $type;
|
||||
//
|
||||
// if (!$ossObjectModel->save()){
|
||||
// throw new AdminException('保存图片失败');
|
||||
// }
|
||||
$ossObjectModel = new OssObject();
|
||||
|
||||
// $this->newId = $ossObjectModel->id;
|
||||
$ossObjectModel->url = $this->newObjectPath;
|
||||
// $ossObjectModel->url = urldecode($this->data['object']);
|
||||
$ossObjectModel->width = $this->data['imageInfo_width'] ?? 0;
|
||||
$ossObjectModel->height = $this->data['imageInfo_height'] ?? 0;
|
||||
$ossObjectModel->audio_second = $this->data['audio_second'] ?? 0;
|
||||
$ossObjectModel->video_duration = $this->data['video_duration'] ?? 0;
|
||||
$ossObjectModel->size = $this->data['size'] ?? 0;
|
||||
|
||||
$ossObjectModel->type = $type;
|
||||
|
||||
if (!$ossObjectModel->save()){
|
||||
throw new AdminException('保存图片失败');
|
||||
}
|
||||
|
||||
$this->newId = $ossObjectModel->id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,7 +304,7 @@ class OssCallbackService
|
||||
private function deleteOssObject(): void
|
||||
{
|
||||
//删除旧的文件
|
||||
$this->redisCache->lPush(CommonRedisKey::getDeleteOssImgListByUrl(), $this->data['object']);
|
||||
$this->redisCache->lPush(CommonRedisKey::getDeleteOssImgListByUrl(), $this->data['object'],'system');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user