-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update * update sample * update to 2.1.3 Co-authored-by: lewzylu <[email protected]>
- Loading branch information
Showing
6 changed files
with
127 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
require dirname(__FILE__) . '/../vendor/autoload.php'; | ||
|
||
$secretId = "COS_SECRETID"; //"云 API 密钥 SecretId"; | ||
$secretKey = "COS_SECRETKEY"; //"云 API 密钥 SecretKey"; | ||
$token = "COS_TMPTOKEN"; //"云 API 临时密钥 Token" | ||
$region = "ap-beijing"; //设置一个默认的存储桶地域 | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, //园区 | ||
'schema' => 'https', //协议头部,默认为http | ||
'timeout' => 10, //超时时间 | ||
'connect_timeout' => 10, //连接超时时间 | ||
'ip' => '', //ip | ||
'port' => '', //端口 | ||
'endpoint' => '', //endpoint | ||
'domain' => '', //自定义域名 | ||
'proxy' => '', //代理服务器 | ||
'retry' => 10, //重试次数 | ||
'userAgent' => '', //UA | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey, | ||
'token' => $token, | ||
'anonymous' => true, //匿名模式 | ||
) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
require dirname(__FILE__) . '/../vendor/autoload.php'; | ||
|
||
$secretId = "COS_SECRETID"; //"云 API 密钥 SecretId"; | ||
$secretKey = "COS_SECRETKEY"; //"云 API 密钥 SecretKey"; | ||
$region = "ap-beijing"; //设置一个默认的存储桶地域 | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'schema' => 'https', //协议头部,默认为http | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
$local_path = "/data/exampleobject"; | ||
|
||
$printbar = function($totolSize, $downloadedSize) { | ||
printf("downloaded [%d/%d]\n", $downloadedSize, $totolSize); | ||
}; | ||
|
||
try { | ||
$result = $cosClient->download( | ||
$bucket = 'examplebucket-125000000', //格式:BucketName-APPID | ||
$key = 'exampleobject', | ||
$saveAs = local_path, | ||
$options=['Progress'=>$printbar, //指定进度条 | ||
'PartSize' => 10 * 1024 * 1024, //分块大小 | ||
'Concurrency' => 5 //并发数 | ||
] | ||
); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters