提交 5e9b5e68 编写于 作者: 李光春's avatar 李光春

- 删除网易云服务

上级 21df3638
## v6.0.72 / 2020-07-09
- 删除网易云服务
## v6.0.71 / 2020-07-09
- 更新请求门面
## v6.0.70 / 2020-07-08
- 更新联盟
- 更新数据库
......@@ -25,7 +25,7 @@ use think\db\exception\ModelNotFoundException;
/**
* 定义当前版本
*/
const VERSION = '6.0.71';
const VERSION = '6.0.72';
if (!function_exists('get_ip_info')) {
......
......@@ -176,15 +176,4 @@ return [
'url' => '',
]
],
// 网易云
'netease' => [
// 云存储
'ks3' => [
'access_key_id' => '',
'access_key_secret' => '',
'endpoint' => '',
'bucket' => '',
'url' => '',
]
],
];
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 :https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 :https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\netease;
use DtApp\ThinkLibrary\Service;
use NOS\Core\NosException;
use NOS\NosClient;
/**
* 网易云
* https://www.163yun.com/product/nos
* Class NosService
* @package DtApp\ThinkLibrary\service\netease
*/
class NosService extends Service
{
private $accessKeyId, $accessKeySecret, $endpoint, $bucket;
public function accessKeyID(string $accessKeyId)
{
$this->accessKeyId = $accessKeyId;
return $this;
}
public function accessKeySecret(string $accessKeySecret)
{
$this->accessKeySecret = $accessKeySecret;
return $this;
}
public function endpoint(string $endpoint)
{
$this->endpoint = $endpoint;
return $this;
}
public function bucket(string $bucket)
{
$this->bucket = $bucket;
return $this;
}
/**
* 获取配置信息
* @return $this
*/
private function getConfig()
{
$this->accessKeyId = $this->app->config->get('dtapp.netease.nos.access_key_id');
$this->accessKeySecret = $this->app->config->get('dtapp.netease.nos.access_key_secret');
$this->endpoint = $this->app->config->get('dtapp.netease.nos.endpoint');
$this->bucket = $this->app->config->get('dtapp.netease.nos.bucket');
return $this;
}
/**
* 上传文件
* @param string $object
* @param string $filePath
* @return bool|string
*/
public function upload(string $object, string $filePath)
{
if (empty($this->accessKeyId)) $this->getConfig();
if (empty($this->accessKeySecret)) $this->getConfig();
if (empty($this->endpoint)) $this->getConfig();
try {
$nosClient = new NosClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
if (empty($this->bucket)) $this->getConfig();
$nosClient->uploadFile($this->bucket, $object, $filePath);
return $this->app->config->get('dtapp.netease.nos.url') . $object;
} catch (NosException $e) {
return false;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册