You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
800 B
42 lines
800 B
<?php
|
|
|
|
namespace ali\oss;
|
|
|
|
use OSS\OssClient;
|
|
use OSS\Core\OssException;
|
|
|
|
class Base
|
|
{
|
|
|
|
// oss配置
|
|
protected $config;
|
|
|
|
/**
|
|
* 构造函数
|
|
* @date 2021-01-19
|
|
*/
|
|
public function __construct(array $data = [])
|
|
{
|
|
$this->config = $data;
|
|
}
|
|
|
|
/**
|
|
* 使用AK&SK初始化账号Client
|
|
* @date 2022-03-26
|
|
*/
|
|
public function createClient()
|
|
{
|
|
try {
|
|
// 初始化
|
|
$oss_client = new OssClient(
|
|
$this->config['access_key_id'], $this->config['access_key_secret'], $this->config['end_point']);
|
|
|
|
// 返回初始化类
|
|
return $oss_client;
|
|
} catch (OssException $e) {
|
|
// 抛出异常
|
|
throw new OssException($e->getMessage());
|
|
}
|
|
|
|
}
|
|
} |