ctms/ctms-api/controllers/client/v1/ObsController.php
fm453 4b842ebf3d ADD:添加后台管理端接口;
DEL:删除不必要的头部注释;
FIX:修正若干已知错误;
2025-06-30 09:40:13 +08:00

59 lines
1.9 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace api\controllers\client\v1;
use Yii;
use yii\data\Pagination;
use vendor\huawei\obsclient\Hwobs;
use vendor\huawei\obsclient\TemporarySignature;
use vendor\huawei\obsclient\PostObject;
class ObsController extends Common
{
public function actionIndex()
{
$apis = [
'getkey'=>'获取访问Key',
];
$this->result('您正使用CMTS系统-华为云OBS接口(尚未开启)', $apis, 200);
}
private function getconf()
{
return [
'id'=> 'ee124c5102064b83bccd2fdda53261cc', //账号ID
'ak'=> '1DYBXUNEPNCIEEQOGGAE',
'sk'=> '0VBI2xPlDB0NtqqVJv3hSFC8DY52G8OYPYNhncGK',
'area'=>'cn-south-1', //华南广州
'endpoint'=>'obs.cn-south-1.myhuaweicloud.com',
'bucketName'=>'hilu-ctms',
];
}
public function actionGetkey()
{
$params = $this->getconf();
$obs = new Hwobs($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
}
public function actionGeturl()
{
$params = $this->getconf();
$obs = new TemporarySignature($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
$res = $obs->UploadUrl($params['bucketName']);
// $res = $obs->getCors($params['bucketName']);
var_dump($res);
// $this->result('获取上传网址成功!', $res, 200);
}
public function actionGetform()
{
$params = $this->getconf();
$obs = new PostObject($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
$obs->init('obs');
$res = $obs->claimPost('hilu-ctms', 'file.jpg');
$url = 'https://'.$params['bucketName'].".".$params['endpoint'];
$res['up_url'] = $url;
$this->result('获取OBS上传准备信息', $res, 200);
}
}