|
| 1 | +<?php |
| 2 | + |
| 3 | +require dirname(__FILE__, 2) . '/vendor/autoload.php'; |
| 4 | + |
| 5 | +$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi |
| 6 | +$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi |
| 7 | +$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket |
| 8 | +$cosClient = new Qcloud\Cos\Client( |
| 9 | + array( |
| 10 | + 'region' => $region, |
| 11 | + 'schema' => 'https', //协议头部,默认为http |
| 12 | + 'credentials'=> array( |
| 13 | + 'secretId' => $secretId , |
| 14 | + 'secretKey' => $secretKey))); |
| 15 | +try { |
| 16 | + // https://cloud.tencent.com/document/product/436/83112 提交多文件打包压缩任务-异步 |
| 17 | + $result = $cosClient->createFileCompressJobs(array( |
| 18 | + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket |
| 19 | + 'Tag' => 'FileCompress', |
| 20 | +// 'QueueId' => 'pcc3ae89sa9d807fs89dg789sdg', |
| 21 | + 'Operation' => array( |
| 22 | + 'UserData' => 'xxx', |
| 23 | + 'FileCompressConfig' => array( |
| 24 | + 'Flatten' => '0', |
| 25 | + 'Format' => 'zip', |
| 26 | +// 'UrlList' => 'test/index.csv', |
| 27 | +// 'Prefix' => 'test/', |
| 28 | + 'Keys' => array( |
| 29 | + 'object1', // 待压缩桶文件 |
| 30 | + 'object2', // 待压缩桶文件 |
| 31 | + 'object3', // 待压缩桶文件 |
| 32 | + ), |
| 33 | + ), |
| 34 | + 'Output' => array( |
| 35 | + 'Region' => $region, |
| 36 | + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket |
| 37 | + 'Object' => 'output/test.zip', |
| 38 | + ), |
| 39 | + ), |
| 40 | +// 'CallBackFormat' => '', |
| 41 | +// 'CallBackType' => '', |
| 42 | +// 'CallBack' => '', |
| 43 | +// 'CallBackMqConfig' => array( |
| 44 | +// 'MqRegion' => '', |
| 45 | +// 'MqMode' => '', |
| 46 | +// 'MqName' => '', |
| 47 | +// ), |
| 48 | + )); |
| 49 | + // 请求成功 |
| 50 | + print_r($result); |
| 51 | +} catch (\Exception $e) { |
| 52 | + // 请求失败 |
| 53 | + echo($e); |
| 54 | +} |
0 commit comments