1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- require dirname(__FILE__) . '/../vendor/autoload.php';
- $secretId = "SECRETID";
- $secretKey = "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($totalSize, $downloadedSize) {
- printf("downloaded [%d/%d]\n", $downloadedSize, $totalSize);
- };
- 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);
- }
|