123456789101112131415161718192021222324252627282930313233 |
- <?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";
- try {
- $imageStyleTemplate = new Qcloud\Cos\ImageParamTemplate\ImageStyleTemplate();
- $imageStyleTemplate->setStyle("stylename");
- $picOperationsTemplate = new \Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
- $picOperationsTemplate->setIsPicInfo(1);
- $picOperationsTemplate->addRule($imageStyleTemplate, "resultobject");
- $result = $cosClient->putObject(array(
- 'Bucket' => 'examplebucket-125000000',
- 'Key' => 'exampleobject',
- 'Body' => fopen($local_path, 'rb'),
- 'PicOperations' => $picOperationsTemplate->queryString(),
- ));
-
- print_r($result);
- } catch (\Exception $e) {
-
- echo($e);
- }
|