Skip to content

Commit 79dd4da

Browse files
committed
feat 删除多余配置
1 parent 812cefb commit 79dd4da

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/Upyun/Api/Form.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public function upload($path, $stream, $params)
2323
'timeout' => $this->config->timeout,
2424
]);
2525

26-
$url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint;
27-
28-
$response = $client->request($method, $url, array(
26+
$response = $client->request($method, $this->endpoint, array(
2927
'multipart' => array(
3028
array(
3129
'name' => 'policy',

src/Upyun/Api/Pretreat.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ class Pretreat
1515
*/
1616
protected $config;
1717

18-
protected $url = 'http://p0.api.upyun.com';
19-
2018
public function __construct(Config $config)
2119
{
2220
$this->config = $config;
@@ -42,7 +40,8 @@ public function process($source, $tasks)
4240
$method = 'POST';
4341
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
4442

45-
$response = $client->request($method, $this->url . $path, [
43+
$url = $this->config->getPretreatEndPoint() . $path;
44+
$response = $client->request($method, $url, [
4645
'headers' => $signedHeaders,
4746
'form_params' => $params
4847
]);
@@ -65,7 +64,7 @@ public function query($taskIds, $path)
6564
$path = $path . '?' . http_build_query($params);
6665

6766
$method = 'GET';
68-
$url = $this->url . $path;
67+
$url = $this->config->getPretreatEndPoint() . $path;
6968
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
7069
$response = $client->request($method, $url, [
7170
'headers' => $signedHeaders

src/Upyun/Api/Rest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Rest
2929
public function __construct(Config $config)
3030
{
3131
$this->config = $config;
32-
$this->endpoint = Config::$restApiEndPoint . '/' . $config->bucketName;
32+
$this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->bucketName;
3333
}
3434

3535
public function request($method, $storagePath)
@@ -62,7 +62,7 @@ public function send()
6262
'timeout' => $this->config->timeout,
6363
]);
6464

65-
$url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint . $this->storagePath;
65+
$url = $this->endpoint . $this->storagePath;
6666
$body = null;
6767
if ($this->file && $this->method === 'PUT') {
6868
$body = $this->file;

src/Upyun/Config.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ class Config
7676
const ED_CNC = 'v2.api.upyun.com';
7777
const ED_CTT = 'v3.api.upyun.com';
7878

79-
/**
80-
* 分块上传接口请求地址
81-
*/
82-
const ED_FORM = 'm0.api.upyun.com';
83-
8479
/**
8580
* 异步云处理接口地址
8681
*/
@@ -123,4 +118,14 @@ public function getVersion()
123118
{
124119
return $this->version;
125120
}
121+
122+
public function getPretreatEndPoint()
123+
{
124+
return $this->getProtocol() . self::ED_VIDEO;
125+
}
126+
127+
public function getProtocol()
128+
{
129+
return $this->useSsl ? 'https://' : 'http://';
130+
}
126131
}

0 commit comments

Comments
 (0)