feat : oss

This commit is contained in:
2024-11-21 11:31:20 +08:00
parent bc8fc54c3d
commit c1c10518cc
3 changed files with 18 additions and 2 deletions

View File

@@ -10,6 +10,8 @@ use App\Service\Admin\Third\AliStsService;
use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware; use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\RequestMapping;
use OSS\OssClient;
use function Hyperf\Config\config;
#[Controller(prefix: "admin/third")] #[Controller(prefix: "admin/third")]
class ThirdController extends AbstractController class ThirdController extends AbstractController
@@ -20,4 +22,19 @@ class ThirdController extends AbstractController
{ {
return (new AliStsService)->handle(); return (new AliStsService)->handle();
} }
#[RequestMapping(path: "sts/test", methods: "GET")]
public function test()
{
$OssClient = new OssClient(
config('ali.access_key_id'),
config('ali.access_key_secret'),
config('ali.oss_endpoint')
);
$bucket = config('ali.bucket');
$url = 'upload/admin/menu/09bd10f1f526296cb3e9bfd624c799ac.jpeg';
$data= $OssClient->deleteObject($bucket, $url);
return $data;
}
} }

View File

@@ -46,7 +46,6 @@ class OssDelByOssIdTask
try { try {
$key = CommonRedisKey::getDeleteOssImgListByOssId(); $key = CommonRedisKey::getDeleteOssImgListByOssId();
$delNum = 0;
$ossIds = []; $ossIds = [];
for ($i = 1; $i < 50; $i++) { for ($i = 1; $i < 50; $i++) {
$one = $this->redis->rPop($key,'system'); $one = $this->redis->rPop($key,'system');

View File

@@ -66,7 +66,7 @@ class OssDelByUrlTask
if (!empty($url)) { if (!empty($url)) {
$delNum++; $delNum++;
$OssClient->deleteObject($bucket, $url); $OssClient->deleteObject($bucket, substr(parse_url($url)['path'],1));
} }
} }