ctms/ctms-api/controllers/gm/v1/ObsController.php
fm453 314745edf8 优化ctms-api语法、修复已知BUG;
主要修复ctms-api、dacms对PHP新版本的支持问题
2025-04-10 23:19:15 +08:00

71 lines
2.0 KiB
PHP
Executable File
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
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-13T09:20:03+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-08-09T09:19:04+08:00
# @Copyright: www.hiluker.cn
//主入口页
namespace api\controllers\gm\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);
}
}