| 12345678910111213141516171819202122232425262728293031 | 
							- <?php
 
- // 临时密钥计算样例
 
- include './qcloud-sts-sdk.php'; // 这里获取 sts.php https://github.com/tencentyun/qcloud-cos-sts-sdk/blob/master/php/sts/sts.php
 
- $sts = new STS();
 
- // 配置参数
 
- $config = array(
 
-     'url' => 'https://sts.tencentcloudapi.com/',
 
-     'domain' => 'sts.tencentcloudapi.com',
 
-     'proxy' => '',
 
-     'secretId' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // 固定密钥
 
-     'secretKey' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // 固定密钥
 
-     'bucket' => 'test-1250000000', // 换成你的 bucket
 
-     'region' => 'ap-guangzhou', // 换成 bucket 所在园区
 
-     'durationSeconds' => 1800, // 密钥有效期
 
-     'allowPrefix' => '*', // 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的目录,例子:* 或者 a/* 或者 a.jpg
 
-     // 密钥的权限列表。简单上传需要以下的权限,其他权限列表请看 https://cloud.tencent.com/document/product/436/31923
 
-     'allowActions' => array (
 
-         // 简单上传
 
-         'name/cos:PutObject',
 
-         'name/cos:PostObject',
 
-     )
 
- );
 
- // 获取临时密钥,计算签名
 
- $tempKeys = $sts->getTempKeys($config);
 
- // 返回数据给前端
 
- header('Content-Type: application/json');
 
- header('Access-Control-Allow-Origin: http://127.0.0.1'); // 这里修改允许跨域访问的网站
 
- header('Access-Control-Allow-Headers: origin,accept,content-type');
 
- echo json_encode($tempKeys);
 
 
  |