Skip to content

Commit

Permalink
Merge pull request #8 from tioncico/master
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
kiss291323003 authored Jan 4, 2020
2 parents 70464f4 + f16072a commit 12804a2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AliYun/Http/RequestHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(Config $config)
{
$headers = [
OssConst::OSS_CONTENT_MD5 => '',
OssConst::OSS_CONTENT_TYPE => OssConst::DEFAULT_CONTENT_TYPE,
OssConst::OSS_CONTENT_TYPE => '',
OssConst::OSS_DATE => gmdate('D, d M Y H:i:s \G\M\T'),
];
$this->headers = $headers;
Expand Down
2 changes: 1 addition & 1 deletion src/AliYun/OssClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ public function auth(array $options)
$httpClient->setHeader('Authorization', $authorization, false);

//如果是预检url,则直接返回
if ($url = $this->preAuth($options, $conjunction, $signature) !== null) {
if (($url = $this->preAuth($options, $signatureStr,$conjunction)) !== null) {
return $url;
}

Expand Down
3 changes: 1 addition & 2 deletions src/AliYun/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ function getStringToSign($signableQueryString,$options, $headers,$hostType){
foreach ($headers as $headerKey => $headerValue) {
$headerValue = str_replace(array("\r", "\n"), '', $headerValue);
$headerKey = strtolower($headerKey);
if ($headerKey === 'content-md5' || $headerKey === 'content-type' || $headerKey === 'date' || (isset($options[OssConst::OSS_PREAUTH]) && (integer)$options[OssConst::OSS_PREAUTH] > 0)) {
if ($headerKey === 'content-md5' || $headerKey === 'content-type' || $headerKey === 'date' || (isset($options['OssConst::OSS_PREAUTH']) && (integer)$options['OssConst::OSS_PREAUTH'] > 0)) {
$stringToSign .= $headerValue . "\n";
} elseif (substr($headerKey, 0, 6) === OssConst::OSS_DEFAULT_PREFIX) {
$stringToSign .= $headerKey . ':' . $headerValue . "\n";
}
}

// 生成 signable_resource
$signableResource = $this->generateSignableResource($options,$hostType);
$stringToSign .= rawurldecode($signableResource) . urldecode($signableQueryString);
Expand Down
17 changes: 15 additions & 2 deletions tests/AliYun/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@
include "../../vendor/autoload.php";
include "../../phpunit2.php";

go(function (){
go(function () {

$config = new \EasySwoole\Oss\AliYun\Config([
'accessKeyId' => ACCESS_KEY_ID,
'accessKeySecret' => ACCESS_KEY_SECRET,
'endpoint' => END_POINT,
]);
$client = new \EasySwoole\Oss\AliYun\OssClient($config);
$data = $client->uploadFile('tioncicoxyz','test1112.jpg','/www/easyswoole/tioncico_oss/tests/Img/test.jpg');
$data = $client->signUrl(OSS_BUCKET,'oss-test.jpg');
var_dump($data);
// var_dump($client->listBuckets());


// $ossClient = new \OSS\OssClient(
// ACCESS_KEY_ID,
// ACCESS_KEY_SECRET,
// END_POINT, false);
// $timeout = 3600;
// $options = array(
// \OSS\OssClient::OSS_PROCESS => "image/resize,m_lfit,h_100,w_100" );
// $data = $ossClient->signUrl(OSS_BUCKET,'oss-test.jpg');
// var_dump($data);

});

0 comments on commit 12804a2

Please sign in to comment.