Skip to content

Commit c28623a

Browse files
committed
fix bugs
1 parent 5eda21d commit c28623a

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
require "vendor/autoload.php";

sample/trafficLimit.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,25 @@
22

33
require dirname(__FILE__) . '/../vendor/autoload.php';
44

5-
$secretId = getenv('SECRET_ID'); //"云 API 密钥 SecretId";
6-
$secretKey = getenv('SECRET_KEY'); //"云 API 密钥 SecretKey";
7-
$region = getenv('COS_REGION'); //设置一个默认的存储桶地域
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
88
$cosClient = new Qcloud\Cos\Client(
99
array(
1010
'region' => $region,
1111
'schema' => 'https', //协议头部,默认为http
1212
'credentials'=> array(
1313
'secretId' => $secretId ,
1414
'secretKey' => $secretKey)));
15-
$local_path = "/Users/tuuna/Desktop/123hello.txt";
16-
17-
$tagSet = http_build_query( array(
18-
urlencode("key1") => urlencode("value1"),
19-
urlencode("key2") => urlencode("value2")),
20-
'',
21-
'&'
22-
);
15+
$local_path = '/data/exampleobject';
2316

2417
try {
2518
//上传对象,单链接限速
2619
$result = $cosClient->putObject(array(
27-
'Bucket' => getenv('COS_BUCKET'), //格式:BucketName-APPID
28-
'Key' => 'test191.txt',
20+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
21+
'Key' => 'exampleobject',
2922
'Body' => fopen($local_path, 'rb'),
30-
'TrafficLimit' => 8 * 1000 * 1000 // 限制为1MB/s
23+
'TrafficLimit' => 8 * 1024 * 1024 // 限制为1MB/s
3124
));
3225
// 请求成功
3326
print_r($result);
@@ -36,8 +29,8 @@
3629
$result = $cosClient->getObject(array(
3730
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
3831
'Key' => 'exampleobject',
39-
'SaveAs' => '/data/exampleobject',
40-
'TrafficLimit' => 8 * 1000 * 1000 // 限制为1MB/s
32+
'SaveAs' => $local_path,
33+
'TrafficLimit' => 8 * 1024 * 1024 // 限制为1MB/s
4134
));
4235
// 请求成功
4336
print_r($result);

src/Qcloud/Cos/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
* @method object GetDetectDocumentResult (array $arg)
105105
*/
106106
class Client extends GuzzleClient {
107-
const VERSION = '2.3.0';
107+
const VERSION = '2.3.1';
108108

109109
public $httpClient;
110110

0 commit comments

Comments
 (0)