Skip to content
Merged
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 src/Qcloud/Cos/BucketStyleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function onCommandAfterPrepare(Event $event) {
{
$bucket = $bucket.'-'.$this->appId;
}
$request->setPath(urldecode($request->getPath()));
// $request->setPath(urldecode($request->getPath()));
$request->getParams()->set('bucket', $bucket)->set('key', $key);

$realHost = $bucket. '.' . $request->getHost();
Expand Down
8 changes: 4 additions & 4 deletions src/Qcloud/Cos/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ public function doesObjectExist($bucket, $key, array $options = array())
}
}
public static function encodeKey($key) {
return $key;
// return $key;
return str_replace('%2F', '/', rawurlencode($key));
}

public static function explodeKey($key) {
// Remove a leading slash if one is found
//return explode('/', $key && $key[0] == '/' ? substr($key, 1) : $key);
return $key;
return ltrim($key, "/");
return explode('/', $key && $key[0] == '/' ? substr($key, 1) : $key);
// return $key;
// return ltrim($key, "/");
}
}
50 changes: 42 additions & 8 deletions src/Qcloud/Cos/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public static function getService() {
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1),
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')),
'UploadId' => array(
'required' => true,
'type' => 'string',
Expand Down Expand Up @@ -133,7 +135,9 @@ public static function getService() {
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1),
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')),
'Parts' => array(
'type' => 'array',
'location' => 'xml',
Expand Down Expand Up @@ -235,6 +239,8 @@ public static function getService() {
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'Metadata' => array(
'type' => 'object',
Expand Down Expand Up @@ -409,6 +415,8 @@ public static function getService() {
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'Metadata' => array(
'type' => 'object',
Expand Down Expand Up @@ -590,7 +598,9 @@ public static function getService() {
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1),
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')),
'MFA' => array(
'type' => 'string',
'location' => 'header',
Expand Down Expand Up @@ -670,6 +680,8 @@ public static function getService() {
'required' => true,
'type' => 'string',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'VersionId' => array(
'type' => 'string',
Expand Down Expand Up @@ -800,7 +812,9 @@ public static function getService() {
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1),
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')),
'Range' => array(
'type' => 'string',
'location' => 'header'),
Expand Down Expand Up @@ -880,6 +894,8 @@ public static function getService() {
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'VersionId' => array(
'type' => 'string',
Expand Down Expand Up @@ -1171,7 +1187,9 @@ public static function getService() {
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1),
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')),
'PartNumber' => array(
'required' => true,
'type' => 'numeric',
Expand Down Expand Up @@ -1264,7 +1282,9 @@ public static function getService() {
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1),
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')),
'Metadata' => array(
'type' => 'object',
'location' => 'header',
Expand Down Expand Up @@ -1444,6 +1464,8 @@ public static function getService() {
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'RequestPayer' => array(
'type' => 'string',
Expand Down Expand Up @@ -1833,6 +1855,8 @@ public static function getService() {
'Key' => array(
'type' => 'string'
),
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey'),
'Value' => array(
'type' => 'string'
),
Expand Down Expand Up @@ -2103,6 +2127,8 @@ public static function getService() {
),
),
),
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
),
),
Expand Down Expand Up @@ -2132,6 +2158,8 @@ public static function getService() {
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'VersionId' => array(
'type' => 'string',
Expand Down Expand Up @@ -2197,7 +2225,9 @@ public static function getService() {
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1),
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')),
'MaxParts' => array(
'type' => 'numeric',
'location' => 'query',
Expand Down Expand Up @@ -2456,6 +2486,8 @@ public static function getService() {
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'Range' => array(
'type' => 'string',
Expand Down Expand Up @@ -2599,6 +2631,8 @@ public static function getService() {
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey')
),
'PartNumber' => array(
'required' => true,
Expand Down Expand Up @@ -2685,7 +2719,7 @@ public static function getService() {
),
'Key' => array(
'type' => 'string',
'location' => 'xml',
'location' => 'xml'
),
'Expiration' => array(
'type' => 'string',
Expand Down
1 change: 1 addition & 0 deletions src/Qcloud/Cos/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public function __construct($accessKey, $secretKey) {
public function __destruct() {
}
public function signRequest(RequestInterface $request) {

$signTime = (string)(time() - 60) . ';' . (string)(time() + 3600);
$httpString = strtolower($request->getMethod()) . "\n" . urldecode($request->getPath()) .
"\n\nhost=" . $request->getHost() . "\n";
Expand Down