Skip to content
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

remeve the deprecated functions of guzzlehttp7.2 and replace with the… #68

Open
wants to merge 4 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
34 changes: 24 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
{
"name": "upyun/sdk",
"name": "v012345/upyun",
"description": "UPYUN sdk for php",
"keywords": ["UPYUN", "sdk"],
"keywords": [
"UPYUN",
"sdk"
],
"type": "library",
"minimum-stability": "stable",
"homepage": "https://github.com/upyun/php-sdk/",
"license": "MIT",
"require": {
"php": ">=5.5.0",
"ext-curl": "*",
"guzzlehttp/guzzle": "~6.0"
"guzzlehttp/guzzle": "~7.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpdocumentor/phpdocumentor": "^2.9",
"consolidation/robo": "^1.0"
},
"autoload": {
"psr-4": { "Upyun\\": "src/Upyun/" }
"psr-4": {
"Upyun\\": "src/Upyun/"
}
},
"autoload-dev": {
"psr-4": { "Upyun\\Tests\\": "tests/" }
"psr-4": {
"Upyun\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"Upyun\\ServiceProvider"
]
}
},
"authors": [
{
Expand All @@ -32,12 +46,12 @@
"email": "[email protected]"
},
{
"name": "totoleo",
"email": "[email protected]"
"name": "totoleo",
"email": "[email protected]"
},
{
"name": "sabakugaara",
"email": "[email protected]"
"name": "sabakugaara",
"email": "[email protected]"
}
]
}
}
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
22 changes: 22 additions & 0 deletions src/Upyun/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Upyun;

class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
protected $defer = true;

public function register()
{
$this->app->singleton(Upyun::class, function () {
return new Upyun(new Config(config('services.upyun.bucket'), config('services.upyun.operator'), config('services.upyun.password')));
});

$this->app->alias(Upyun::class, 'upyun');
}

public function provides()
{
return [Upyun::class, 'upyun'];
}
}
10 changes: 5 additions & 5 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 @@ -67,7 +67,7 @@ private function pointUpload($path, $stream, $params)
$res = $req->request('PUT', $path)
->withHeaders(array_merge(array(
'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 @@ -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 @@ -24,7 +24,7 @@ class Upyun
{

/**
* @var Config: 服务配置
* @var Config 服务配置
*/
protected $config;

Expand Down 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