Skip to content

Commit eca1de2

Browse files
committed
Fixed getBucketLocation / getBucket issues in v4 signature.
1 parent 4ff3b0a commit eca1de2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

S3.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,10 +1984,9 @@ private static function __getHash($string)
19841984
* @param string $method
19851985
* @param string $uri
19861986
* @param string $data
1987-
* @param array $parameters
19881987
* @return array $headers
19891988
*/
1990-
public static function __getSignatureV4($aHeaders, $headers, $method='GET', $uri='', $data = '', $parameters=array())
1989+
public static function __getSignatureV4($aHeaders, $headers, $method='GET', $uri='', $data = '')
19911990
{
19921991
$service = 's3';
19931992
$region = S3::getRegion();
@@ -2014,10 +2013,17 @@ public static function __getSignatureV4($aHeaders, $headers, $method='GET', $uri
20142013
// payload
20152014
$payloadHash = isset($amzHeaders['x-amz-content-sha256']) ? $amzHeaders['x-amz-content-sha256'] : hash('sha256', $data);
20162015

2016+
// parameters
2017+
$parameters = array();
2018+
if (strpos($uri, '?')) {
2019+
list ($uri, $query_str) = @explode("?", $uri);
2020+
parse_str($query_str, $parameters);
2021+
}
2022+
20172023
// CanonicalRequests
20182024
$amzRequests[] = $method;
20192025
$amzRequests[] = $uri;
2020-
$amzRequests[] = http_build_query($parameters);
2026+
$amzRequests[] = http_build_query($parameters);
20212027
// add header as string to requests
20222028
foreach ( $amzHeaders as $k => $v ) {
20232029
$amzRequests[] = $k . ':' . $v;
@@ -2372,8 +2378,7 @@ public function getResponse()
23722378
$this->headers,
23732379
$this->verb,
23742380
$this->uri,
2375-
$this->data,
2376-
$this->parameters
2381+
$this->data
23772382
);
23782383
foreach ($amzHeaders as $k => $v) {
23792384
$headers[] = $k .': '. $v;

0 commit comments

Comments
 (0)