修改云存储

This commit is contained in:
JaguarJack 2019-01-30 17:14:45 +08:00
parent 56362ae33f
commit b821d02b1a
7 changed files with 46 additions and 25 deletions

View File

@ -14,15 +14,15 @@ return [
// 又拍驱动
'uppay' => \thinking\icloud\cloud\UpYunCloud::class,
// 七牛驱动认证
'qinniuAuth' => \thinking\icloud\auth\QiniuAuth::class,
'qiniuAuth' => \thinking\icloud\auth\QiNiuAuth::class,
// 又拍驱动认证
'uppay' => \thinking\icloud\auth\UpYunAuth::class,
'uppayAuth' => \thinking\icloud\auth\UpYunAuth::class,
],
/* 七牛配置信息 */
'qiniu' => [
'app_key' => '',
'app_secret' => '',
'app_key' => 'dw1jkmtSNjxyPkMdyBfVeaWzCAOiMSOTk35adV8W',
'app_secret' => '_KfsmnV8d-rlYtABD27xF7y-ZNxblvdk9_VVZ67g',
//上传策略字段,上传凭证校验使用
'policyFields' => [
@ -56,11 +56,14 @@ return [
'buckets' => [''],
],
'oss' => [
'access_key' => '',
'access_secret' => '',
],
//api接口
'host' => [
//七牛host
'rs' => 'rs.qiniu.com',
'rs' => 'rs.qbox.me',
'api' => 'api.qiniu.com',
'uc' => 'uc.qbox.me',
'rsf' => 'rsf.qbox.me',

View File

@ -7,9 +7,10 @@
*/
namespace thinking\icloud;
use thinking\icloud\auth\AuthFactory;
use thinking\icloud\Utility;
use thinking\icloud\factory\AuthFactory;
use thinking\icloud\httpclient\Client;
use thinking\icloud\exception\NotFoundException;
use thinking\icloud\Utility;
class AbstractCloud
{
@ -40,7 +41,6 @@ class AbstractCloud
if (!array_key_exists($host, $this->host)) {
throw NotFoundException::NotFoundKey("Host Key '{$host}' Not Found In Config File");
}
return self::getHost($host, $isHttps);
}
@ -61,16 +61,14 @@ class AbstractCloud
{
// TODO: Implement __call() method.
$client = new Client;
$client->url = $arguments[0];
$this->method = $name;
$client->uri = $arguments[0];
$client->method = $name;
if (isset($arguments[1]['headers']['Authorization'])) {
$client->params = $arguments[1];
} else {
$headers = AuthFactory::authorization($arguments[0], $name);
$client->params = array_merge_recursive(['headers' => $headers], $arguments[1]);
$client->params = array_merge_recursive(['headers' => $headers], $arguments[1] ?? []);
}
return $client->send();
}

View File

@ -32,7 +32,7 @@ trait Utility
*/
public static function getHost(string $host = 'rs', bool $isHttps = false)
{
return $isHttps ? 'https://' : 'http://' . config('icloud.host.'. strtolower($host));
return $isHttps ? 'https://' : 'http://' . config('cloud.host.'. strtolower($host));
}
/**

View File

@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/1/30
* Time: 16:32
*/
namespace thinking\icloud\auth;
use thinking\icloud\Utility;
final class OssAuth
{
use Utility;
}

View File

@ -9,7 +9,7 @@ namespace thinking\icloud\auth;
use thinking\icloud\Utility;
final class QiniuAuth
final class QiNiuAuth
{
use Utility;
@ -37,9 +37,8 @@ final class QiniuAuth
*/
public static function getAccessToken(string $urlString, string $body, string $contentType = '')
{
$appKey = config('cloud.qiniu.appKey');
$appSecret = config('cloud.qiniu.appSecret');
$appKey = config('cloud.qiniu.app_key');
$appSecret = config('cloud.qiniu.app_secret');
$url = parse_url($urlString);
$data = '';
if (array_key_exists('path', $url)) {
@ -76,8 +75,8 @@ final class QiniuAuth
string $policy = '',
bool $strictPolicy = true
){
$appKey = config('cloud.qiniu.appKey');
$appSecret = config('cloud.qiniu.appSecret');
$appKey = config('cloud.qiniu.app_key');
$appSecret = config('cloud.qiniu.app_secret');
$scope = $key ? sprintf('%s:%s', $bucket, $key) : $bucket;
$deadline = time() + $expires;
@ -120,8 +119,8 @@ final class QiniuAuth
*/
public static function dowmloadToken(string $uri, int $expires = 3600)
{
$appSecret = config('cloud.qiniu.appSecret');
$appKey = config('cloud.qiniu.appKey');
$appSecret = config('cloud.qiniu.app_secret');
$appKey = config('cloud.qiniu.app_key');
$uri = sprintf('%s?e=%s', $uri, time() + $expires);

View File

@ -20,9 +20,7 @@ class AuthFactory
public static function create(string $name, ...$argument)
{
$defaultDriver = config('cloud.driver.default');
$auth = config('cloud.driver.' . $defaultDriver . 'Auth');
return $auth::$name(...$argument);
}

View File

@ -11,7 +11,13 @@ use GuzzleHttp\Client as HttpClient;
class Client implements \ArrayAccess
{
protected $params = [];
protected $client = null;
protected $method = null;
protected $uri = null;
/**
* 发送数据
*