Skip to content

feat 删除多余配置 #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/Upyun/Api/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public function upload($path, $stream, $params)
'timeout' => $this->config->timeout,
]);

$url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint;

$response = $client->request($method, $url, array(
$response = $client->request($method, $this->endpoint, array(
'multipart' => array(
array(
'name' => 'policy',
Expand Down
7 changes: 3 additions & 4 deletions src/Upyun/Api/Pretreat.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Pretreat
*/
protected $config;

protected $url = 'http://p0.api.upyun.com';

public function __construct(Config $config)
{
$this->config = $config;
Expand All @@ -42,7 +40,8 @@ public function process($source, $tasks)
$method = 'POST';
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);

$response = $client->request($method, $this->url . $path, [
$url = $this->config->getPretreatEndPoint() . $path;
$response = $client->request($method, $url, [
'headers' => $signedHeaders,
'form_params' => $params
]);
Expand All @@ -65,7 +64,7 @@ public function query($taskIds, $path)
$path = $path . '?' . http_build_query($params);

$method = 'GET';
$url = $this->url . $path;
$url = $this->config->getPretreatEndPoint() . $path;
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
$response = $client->request($method, $url, [
'headers' => $signedHeaders
Expand Down
4 changes: 2 additions & 2 deletions src/Upyun/Api/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Rest
public function __construct(Config $config)
{
$this->config = $config;
$this->endpoint = Config::$restApiEndPoint . '/' . $config->bucketName;
$this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->bucketName;
}

public function request($method, $storagePath)
Expand Down Expand Up @@ -62,7 +62,7 @@ public function send()
'timeout' => $this->config->timeout,
]);

$url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint . $this->storagePath;
$url = $this->endpoint . $this->storagePath;
$body = null;
if ($this->file && $this->method === 'PUT') {
$body = $this->file;
Expand Down
15 changes: 10 additions & 5 deletions src/Upyun/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ class Config
const ED_CNC = 'v2.api.upyun.com';
const ED_CTT = 'v3.api.upyun.com';

/**
* 分块上传接口请求地址
*/
const ED_FORM = 'm0.api.upyun.com';

/**
* 异步云处理接口地址
*/
Expand Down Expand Up @@ -123,4 +118,14 @@ public function getVersion()
{
return $this->version;
}

public function getPretreatEndPoint()
{
return $this->getProtocol() . self::ED_VIDEO;
}

public function getProtocol()
{
return $this->useSsl ? 'https://' : 'http://';
}
}