123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
-
- require dirname(__FILE__) . '/../vendor/autoload.php';
-
- $secretId = "COS_SECRETID";
- $secretKey = "COS_SECRETKEY";
- $region = "ap-beijing";
- $cosClient = new Qcloud\Cos\Client(
- array(
- 'region' => $region,
- 'schema' => 'https',
- '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',
- $key = 'exampleobject',
- $saveAs = $local_path,
- $options=['Progress' => $printbar,
- 'PartSize' => 10 * 1024 * 1024,
- 'Concurrency' => 5,
- 'ResumableDownload' => true,
- 'ResumableTaskFile' => 'tmp.cosresumabletask'
- ]
- );
-
- print_r($result);
- } catch (\Exception $e) {
-
- echo($e);
- }
|