Skip to content

Commit af38fe3

Browse files
support signature v4
--------- Co-authored-by: yangpeng <[email protected]>
1 parent bb6d2e5 commit af38fe3

35 files changed

+4009
-1210
lines changed

src/OSS/Core/OssUtil.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,4 +531,13 @@ public static function decodeKey($key, $encoding)
531531
throw new OssException("Unrecognized encoding type: " . $encoding);
532532
}
533533
}
534+
535+
public static function unparseUrl($parsed_url) {
536+
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
537+
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
538+
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
539+
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
540+
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
541+
return "$scheme$host$port$path$query";
542+
}
534543
}

src/OSS/OssClient.php

Lines changed: 503 additions & 555 deletions
Large diffs are not rendered by default.

src/OSS/Result/CreateBucketCnameTokenResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class CreateBucketCnameTokenResult extends Result
88
{
99
/**
10-
* @return CnameConfig
10+
* @return CnameTokenInfo
1111
*/
1212
protected function parseDataFromResponse()
1313
{

src/OSS/Result/GetBucketInfoResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class GetBucketInfoResult extends Result
1616
/**
1717
* Parse data from response
1818
*
19-
* @return string
19+
* @return BucketInfo
2020
* @throws OssException
2121
*/
2222
protected function parseDataFromResponse()

src/OSS/Result/GetLiveChannelHistoryResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class GetLiveChannelHistoryResult extends Result
88
{
99
/**
10-
* @return
10+
* @return GetLiveChannelHistory
1111
*/
1212
protected function parseDataFromResponse()
1313
{

src/OSS/Result/GetLiveChannelInfoResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class GetLiveChannelInfoResult extends Result
88
{
99
/**
10-
* @return
10+
* @return GetLiveChannelInfo
1111
*/
1212
protected function parseDataFromResponse()
1313
{

src/OSS/Result/ListObjectVersionsResult.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OSS\Result;
44

5+
use OSS\Core\OssException;
56
use OSS\Core\OssUtil;
67
use OSS\Model\ObjectVersionInfo;
78
use OSS\Model\ObjectVersionListInfo;
@@ -17,11 +18,12 @@ class ListObjectVersionsResult extends Result
1718
/**
1819
* Parse the xml data returned by the ListObjectVersions interface
1920
*
20-
* return ObjectVersionListInfo
21+
* @return ObjectVersionListInfo
22+
* @throws OssException
2123
*/
2224
protected function parseDataFromResponse()
2325
{
24-
$xml = simplexml_load_string($this->rawResponse->body);
26+
$xml = simplexml_load_string($this->rawResponse->body);
2527
$encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
2628
$objectVersionList = $this->parseObjecVersionList($xml, $encodingType);
2729
$deleteMarkerList = $this->parseDeleteMarkerList($xml, $encodingType);
@@ -40,8 +42,8 @@ protected function parseDataFromResponse()
4042
$delimiter = OssUtil::decodeKey($delimiter, $encodingType);
4143
$isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
4244

43-
return new ObjectVersionListInfo($bucketName, $prefix, $keyMarker, $nextKeyMarker,
44-
$versionIdMarker, $nextVersionIdMarker,$maxKeys, $delimiter, $isTruncated,
45+
return new ObjectVersionListInfo($bucketName, $prefix, $keyMarker, $nextKeyMarker,
46+
$versionIdMarker, $nextVersionIdMarker, $maxKeys, $delimiter, $isTruncated,
4547
$objectVersionList, $deleteMarkerList, $prefixList);
4648
}
4749

src/OSS/Result/ListObjectsResult.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OSS\Result;
44

5+
use OSS\Core\OssException;
56
use OSS\Core\OssUtil;
67
use OSS\Model\ObjectInfo;
78
use OSS\Model\ObjectListInfo;
@@ -16,7 +17,8 @@ class ListObjectsResult extends Result
1617
/**
1718
* Parse the xml data returned by the ListObjects interface
1819
*
19-
* return ObjectListInfo
20+
* @return ObjectListInfo
21+
* @throws OssException
2022
*/
2123
protected function parseDataFromResponse()
2224
{

src/OSS/Result/ListObjectsV2Result.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OSS\Result;
44

5+
use OSS\Core\OssException;
56
use OSS\Core\OssUtil;
67
use OSS\Model\ObjectInfo;
78
use OSS\Model\ObjectListInfoV2;
@@ -16,7 +17,8 @@ class ListObjectsV2Result extends Result
1617
/**
1718
* Parse the xml data returned by the ListObjectsV2 interface
1819
*
19-
* return ObjectListInfoV2
20+
* @return ObjectListInfoV2
21+
* @throws OssException
2022
*/
2123
protected function parseDataFromResponse()
2224
{
@@ -34,7 +36,7 @@ protected function parseDataFromResponse()
3436
$continuationToken = isset($xml->ContinuationToken) ? strval($xml->ContinuationToken) : "";
3537
$nextContinuationToken = isset($xml->NextContinuationToken) ? strval($xml->NextContinuationToken) : "";
3638
$startAfter = isset($xml->StartAfter) ? strval($xml->StartAfter) : "";
37-
$startAfter = OssUtil::decodeKey($startAfter, $encodingType);
39+
$startAfter = OssUtil::decodeKey($startAfter, $encodingType);
3840
$keyCount = isset($xml->KeyCount) ? intval($xml->KeyCount) : 0;
3941
return new ObjectListInfoV2($bucketName, $prefix, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList, $continuationToken, $nextContinuationToken, $startAfter, $keyCount);
4042
}

src/OSS/Signer/SignerInterface.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace OSS\Signer;
3+
4+
use OSS\Http\RequestCore;
5+
use OSS\Credentials\Credentials;
6+
7+
interface SignerInterface
8+
{
9+
public function sign(RequestCore $request, Credentials $credentials, array &$options);
10+
11+
public function presign(RequestCore $request, Credentials $credentials, array &$options);
12+
}

0 commit comments

Comments
 (0)