#tradewind:add COS automatically convert to DEEP_ARCHIVE
This commit is contained in:
51
jobs/cos.php
Normal file
51
jobs/cos.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../init.php';
|
||||
|
||||
global $globalConfig;
|
||||
|
||||
$bucket = $globalConfig['bucket'];
|
||||
$secretId = $globalConfig['secretId'];
|
||||
$secretKey = $globalConfig['secretKey'];
|
||||
$region = $globalConfig['region'];
|
||||
|
||||
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $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);
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
Reference in New Issue
Block a user