diff --git a/composer.json b/composer.json index 2d8c00c..987e767 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ }, "require": { "php": ">=7.1.0", + "qcloud/cos-sdk-v5": ">=2.0", "cloudflare/sdk": "^1.1", "guzzlehttp/guzzle": "~6.0" } diff --git a/etc/config.example.php b/etc/config.example.php index 972f017..c9786c0 100644 --- a/etc/config.example.php +++ b/etc/config.example.php @@ -10,3 +10,9 @@ $globalConfig['cloudflare'] = [ $globalConfig['dingtalk_token'] = 'your_token'; +$globalConfig['COS'] = [ + 'bucket' => 'bucket', //存储桶名称 格式:BucketName-APPID + 'secretId' => 'secretId', //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi + 'secretKey' => 'secretKey', //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi + 'region' => 'region', //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket +]; diff --git a/jobs/cos.php b/jobs/cos.php new file mode 100644 index 0000000..b615f85 --- /dev/null +++ b/jobs/cos.php @@ -0,0 +1,51 @@ + $region, + 'schema' => 'https', //协议头部,默认为http + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey, + ) + ) +); + +try { + $result = $cosClient->listObjects(['Bucket' => $bucket]); + // 请求成功 + if (isset($result['Contents'])) { + + foreach ($result['Contents'] as $rt) { + if ($rt['StorageClass'] !== 'DEEP_ARCHIVE') { + $result = $cosClient->Copy( + $bucket, + $rt['Key'], //此处的 key 为对象键 + [ + 'Region' => $region, + 'Bucket' => $bucket, + 'Key' => $rt['Key'], + ], + [ + 'StorageClass' => 'DEEP_ARCHIVE' + ] + ); + var_dump(json_encode($result)); + } + } + } +} catch (\Exception $e) { + var_dump($e); +} + + diff --git a/jobs/ddns.php b/jobs/ddns.php index 39d62b9..d32a819 100644 --- a/jobs/ddns.php +++ b/jobs/ddns.php @@ -29,7 +29,7 @@ try { } -$realIp = shell_exec('curl -s ip.sb'); +$realIp = shell_exec('curl -s -4 ip.sb'); $realIp = str_replace("\n", "", $realIp); if (!empty($realIp)) {