Skip to content

Commit 9f6b67b

Browse files
authored
Add support for global acceleration downlink traffic in charts (#78)
1 parent b56df30 commit 9f6b67b

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

cos-sdk-v5/src/Monitor/Charts.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public static function traffic($data)
9797
$series = [
9898
['name' => '外网下行流量', 'data' => $data['internet']],
9999
['name' => '内网下行流量', 'data' => $data['internal']],
100-
['name' => 'CDN 回源流量', 'data' => $data['cdn']]
100+
['name' => 'CDN 回源流量', 'data' => $data['cdn']],
101+
['name' => '全球加速下行流量', 'data' => $data['accelerate']],
101102
];
102103

103104
return self::generateChartScript('cos-traffic-chart', '流量', $series, $data['date'], 'MB');

cos-sdk-v5/src/Monitor/DataPoints.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class DataPoints
2525
const METRIC_STORAGE = 'StdStorage'; // 标准存储-存储空间
2626
const METRIC_OBJECT_NUMBER = 'StdObjectNumber'; // 标准存储-对象数量
2727

28+
const METRIC_ACCELER_TRAFFIC_DOWN = 'AccelerTrafficDown'; // 全球加速下行流量
2829
const METRIC_INTERNET_TRAFFIC = 'InternetTraffic'; // 外网下行流量
2930
const METRIC_INTERNAL_TRAFFIC = 'InternalTraffic'; // 内网下行流量
3031
const METRIC_CDN_ORIGIN_TRAFFIC = 'CdnOriginTraffic'; // CDN 回源流量
@@ -252,11 +253,15 @@ public function getTraffic()
252253
$params = $this->buildParams(self::METRIC_CDN_ORIGIN_TRAFFIC);
253254
$cdn = $this->request($params);
254255

256+
$params = $this->buildParams(self::METRIC_ACCELER_TRAFFIC_DOWN);
257+
$accelerate = $this->request($params);
258+
255259
return [
256260
'date' => $date,
257261
'internet' => array_map([$this, 'bytes2MB'], $internet->Values ?? []),
258262
'internal' => array_map([$this, 'bytes2MB'], $internal->Values ?? []),
259263
'cdn' => array_map([$this, 'bytes2MB'], $cdn->Values ?? []),
264+
'accelerate' => array_map([$this, 'bytes2MB'], $accelerate->Values ?? []),
260265
];
261266
}
262267

readme.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: COS, 腾讯云, 对象存储, Tencent, Qcloud
55
Requires at least: 4.6
66
Tested up to: 6.7
77
Requires PHP: 7.2
8-
Stable tag: 2.6.2
8+
Stable tag: 2.6.3
99
License: Apache2.0
1010
License URI: http://www.apache.org/licenses/LICENSE-2.0.html
1111

@@ -105,6 +105,7 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
105105

106106
= Stable =
107107

108+
- Add support for global acceleration downlink traffic in charts
108109
- Fix URL style appending logic
109110

110111
= Other =

sync-qcloud-cos.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Sync QCloud COS
44
Plugin URI: https://qq52o.me/2518.html
55
Description: 使用腾讯云对象存储服务 COS 作为附件存储空间。(Using Tencent Cloud Object Storage Service COS as Attachment Storage Space.)
6-
Version: 2.6.2
6+
Version: 2.6.3
77
Author: 沈唁
88
Author URI: https://qq52o.me
99
License: Apache2.0
@@ -27,7 +27,7 @@
2727
use SyncQcloudCos\Monitor\DataPoints;
2828
use SyncQcloudCos\Object\Head;
2929

30-
define('COS_VERSION', '2.6.2');
30+
define('COS_VERSION', '2.6.3');
3131
define('COS_PLUGIN_SLUG', 'sync-qcloud-cos');
3232
define('COS_PLUGIN_PAGE', plugin_basename(dirname(__FILE__)) . '%2F' . basename(__FILE__));
3333

@@ -131,12 +131,11 @@ function cos_check_bucket($cos_options)
131131
} elseif ($errorCode == ErrorCode::ACCESS_DENIED) {
132132
$message = '<code>SecretID</code> 或 <code>SecretKey</code> 有误,请检查配置信息!';
133133
}
134-
echo "<div class='error'><p><strong>{$message}</strong></p></div>";
135134
} catch (\Throwable $e) {
136135
$message = (string)$e;
137-
echo "<div class='error'><p><strong>{$message}</strong></p></div>";
138136
}
139137

138+
echo "<div class='error'><p><strong>{$message}</strong></p></div>";
140139
return false;
141140
}
142141

@@ -561,14 +560,14 @@ function cos_delete_remote_attachment($post_id)
561560
add_action('delete_attachment', 'cos_delete_remote_attachment');
562561

563562
// 当upload_path为根目录时,需要移除URL中出现的“绝对路径”
564-
function cos_modefiy_img_url($url, $post_id)
563+
function cos_modify_img_url($url, $post_id)
565564
{
566565
// 移除 ./ 和 项目根路径
567566
return str_replace(['./', get_home_path()], '', $url);
568567
}
569568

570569
if (cos_get_option('upload_path') == '.') {
571-
add_filter('wp_get_attachment_url', 'cos_modefiy_img_url', 30, 2);
570+
add_filter('wp_get_attachment_url', 'cos_modify_img_url', 30, 2);
572571
}
573572

574573
function cos_sanitize_file_name($filename)
@@ -938,7 +937,7 @@ function cos_sync_setting_form($cos_options)
938937
<input type="hidden" name="type" value="qcloud_cos_all">
939938
<td>
940939
<input type="submit" class="button button-secondary" value="开始同步"/>
941-
<p><b>注意:如果是首次同步,执行时间将会非常长(根据你的历史附件数量),有可能会因为执行时间过长,导致页面显示超时或者报错。<br> 所以,建议附件数量过多的用户,直接使用官方的<a target="_blank" rel="nofollow" href="https://cloud.tencent.com/document/product/436/63143">COSCLI 工具</a>进行迁移,具体可参考<a target="_blank" rel="nofollow" href="https://qq52o.me/2809.html">使用 COSCLI 快速迁移本地数据到 COS</a></b></p>
940+
<p><b>注意:如果是首次同步,执行时间将会非常长(根据你的历史附件数量),有可能会因为执行时间过长,导致页面显示超时或者报错。<br> 所以建议附件数量过多的用户,直接使用官方的<a target="_blank" rel="nofollow" href="https://cloud.tencent.com/document/product/436/63143">COSCLI 工具</a>进行迁移,具体可参考<a target="_blank" rel="nofollow" href="https://qq52o.me/2809.html">使用 COSCLI 快速迁移本地数据到 COS</a></b></p>
942941
</td>
943942
</tr>
944943
</table>
@@ -1104,7 +1103,7 @@ function cos_ci_image_slim_page($options)
11041103
<input type="checkbox" name="ci_image_slim_mode[]" value="API" {$checked_mode_api} />
11051104
<span class="slider round"></span>
11061105
</label>
1107-
<p>开通极智压缩的 API 使用方式,开通后可在图片时通过极智压缩参数(需要配置配置图片处理样式<code>?imageSlim</code>)对图片进行压缩;</p>
1106+
<p>开通极智压缩的 API 使用方式,开通后可在图片时通过极智压缩参数(需要配置图片处理样式<code>?imageSlim</code>)对图片进行压缩;</p>
11081107
</td>
11091108
</tr>
11101109
<tr>
@@ -1383,7 +1382,7 @@ function cos_document_page($options)
13831382
}
13841383

13851384
$disableSubmit = !$status ? 'disabled=disabled' : '';
1386-
$disableMessage = !$status ? "<p>如需使用请先访问 <a href='https://console.cloud.tencent.com/ci/bucket?bucket={$bucket}&region={$options['regional']}&type=document' target='_blank'>腾讯云控制台</a>开启。</p>" : '';
1385+
$disableMessage = !$status ? "<p>如需使用请先访问 <a href='https://console.cloud.tencent.com/ci/bucket?bucket={$bucket}&region={$options['regional']}&type=document' target='_blank'>腾讯云控制台</a> 开启。</p>" : '';
13871386

13881387
return <<<EOF
13891388
<form method="post">

0 commit comments

Comments
 (0)