Skip to content

增加 guzzle7 的支持 #70

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SDK 包含如下功能
建议使用速度很快的国内[全量镜像](https://pkg.phpcomposer.com/#how-to-use-packagist-mirror)([又拍云赞助](https://pkg.phpcomposer.com/#donation))

```
composer require upyun/sdk
composer require alapi/upyun-sdk
```

2.如果不适应 `composer` 管理,可以直接下载[压缩包](https://github.com/upyun/php-sdk/releases)(注意需要下载 `php-sdk-版本号.zip` 格式的 zip 压缩包,不是 Source code 源码压缩包),解压后,项目中添加如下代码:
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "upyun/sdk",
"name": "alapi/upyun-sdk",
"description": "UPYUN sdk for php",
"keywords": ["UPYUN", "sdk"],
"type": "library",
"minimum-stability": "stable",
"homepage": "https://github.com/upyun/php-sdk/",
"license": "MIT",
"require": {
"php": ">=5.5.0",
"php": "^7.2.5 || ^8.0",
"ext-curl": "*",
"guzzlehttp/guzzle": "~6.0"
"guzzlehttp/guzzle": "~7.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down Expand Up @@ -38,6 +39,10 @@
{
"name": "sabakugaara",
"email": "senellise@gmail.com"
},
{
"name": "alapi",
"email": "im@alone88.cn"
}
]
}
2 changes: 1 addition & 1 deletion src/Upyun/Api/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function request($method, $storagePath)
*/
public function withFile($file)
{
$stream = Psr7\stream_for($file);
$stream = Psr7\Utils::streamFor($file);
$this->file = $stream;

return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/Upyun/Api/SyncVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function process($params, $path) {
'json' => $params
]);

$body = $response->getBody()->getContents();
$body = (string)$response->getBody();
return json_decode($body, true);
}
}
}
10 changes: 5 additions & 5 deletions src/Upyun/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public static function getPurgeSignHeader(Config $serviceConfig, $urlString)
/**
* 获取表单 API 需要的签名,依据 body 签名规则计算
* @param Config $serviceConfig
* @param $method 请求方法
* @param $uri 请求路径
* @param $date 请求时间
* @param $method string 请求方法
* @param $uri string 请求路径
* @param $date string 请求时间
* @param $policy
* @param $contentMd5 请求 body 的 md5
* @param $contentMd5 string 请求 body 的 md5
*
* @return array
* @return string
*/
public static function getBodySignature(Config $serviceConfig, $method, $uri, $date = null, $policy = null, $contentMd5 = null)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Upyun/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(Config $config)

public function upload($path, $file, $params, $withAsyncProcess)
{
$stream = Psr7\stream_for($file);
$stream = Psr7\Utils::streamFor($file);
$size = $stream->getSize();
$useBlock = $this->needUseBlock($size);

Expand Down Expand Up @@ -87,7 +87,7 @@ private function pointUpload($path, $stream, $params)
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Part-Id' => $partId
))
->withFile(Psr7\stream_for($fileBlock))
->withFile(Psr7\Utils::streamFor($fileBlock))
->send();

if ($res->getStatusCode() !== 204) {
Expand Down Expand Up @@ -146,7 +146,7 @@ private function concurrentPointUpload($path, $stream, $params)
->withHeaders(array_merge(array(
'X-Upyun-Multi-Disorder' => 'true',
'X-Upyun-Multi-Stage' => 'initiate',
'X-Upyun-Multi-Type' => Psr7\mimetype_from_filename($path),
'X-Upyun-Multi-Type' => Psr7\MimeType::fromFilename($path),
'X-Upyun-Multi-Length' => $stream->getSize(),
), $headers))
->send();
Expand All @@ -167,7 +167,7 @@ private function concurrentPointUpload($path, $stream, $params)
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Part-Id' => $i
))
->withFile(Psr7\stream_for($fileBlock))
->withFile(Psr7\Utils::streamFor($fileBlock))
->toRequest();
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/Upyun/Upyun.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function read($path, $saveHandler = null, $params = array())

if (! isset($params['x-upyun-list-iter'])) {
if (is_resource($saveHandler)) {
Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler));
Psr7\Utils::copyToStream($response->getBody(), Psr7\Utils::streamFor($saveHandler));
return true;
} else {
return $response->getBody()->getContents();
Expand Down Expand Up @@ -351,7 +351,7 @@ public function purge($urls)
'headers' => Signature::getPurgeSignHeader($this->config, $urlString),
'form_params' => ['purge' => $urlString]
]);
$result = json_decode($response->getBody()->getContents(), true);
$result = json_decode((string)$response->getBody(), true);
return $result['invalid_domain_of_url'];
}

Expand Down