123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?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, $uploadedSize) {
- printf("uploaded [%d/%d]\n", $uploadedSize, $totolSize);
- };
-
- try {
- $result = $cosClient->upload(
- $bucket = 'examplebucket-125000000',
- $key = 'exampleobject',
- $body = fopen($local_path, 'rb')
-
-
- );
-
- print_r($result);
- } catch (\Exception $e) {
-
- echo($e);
- }
|