Fix endpoint failed to use https (#42)

pull/43/head v1.4.17
Luffy 2024-08-01 08:20:11 +08:00 committed by GitHub
parent 69626aa636
commit 28df5b05f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -3,7 +3,7 @@
Plugin Name: OSS Aliyun Plugin Name: OSS Aliyun
Plugin URI: https://github.com/sy-records/aliyun-oss-wordpress Plugin URI: https://github.com/sy-records/aliyun-oss-wordpress
Description: 使用阿里云对象存储 OSS 作为附件存储空间。This is a plugin that uses Aliyun Object Storage Service for attachments remote saving. Description: 使用阿里云对象存储 OSS 作为附件存储空间。This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.
Version: 1.4.16 Version: 1.4.17
Author: 沈唁 Author: 沈唁
Author URI: https://qq52o.me Author URI: https://qq52o.me
License: Apache2.0 License: Apache2.0
@ -19,7 +19,7 @@ use OSS\Credentials\CredentialsProvider;
use AlibabaCloud\Credentials\Credential; use AlibabaCloud\Credentials\Credential;
use OSS\Credentials\StaticCredentialsProvider; use OSS\Credentials\StaticCredentialsProvider;
define('OSS_VERSION', '1.4.16'); define('OSS_VERSION', '1.4.17');
define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__))); define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__)));
if (!function_exists('get_home_path')) { if (!function_exists('get_home_path')) {
@ -103,11 +103,12 @@ function oss_get_client()
function oss_get_bucket_endpoint($oss_options) function oss_get_bucket_endpoint($oss_options)
{ {
$regional = esc_attr($oss_options['regional']); $regional = esc_attr($oss_options['regional']);
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http';
if ($oss_options['is_internal'] == 'true') { if ($oss_options['is_internal'] == 'true') {
return "https://{$regional}-internal.aliyuncs.com"; return "{$protocol}://{$regional}-internal.aliyuncs.com";
} }
return "https://{$regional}.aliyuncs.com"; return "{$protocol}://{$regional}.aliyuncs.com";
} }
function oss_get_bucket_name() function oss_get_bucket_name()

View File

@ -5,7 +5,7 @@ Tags: oss, 阿里云, 对象存储, aliyun
Requires at least: 4.6 Requires at least: 4.6
Tested up to: 6.6 Tested up to: 6.6
Requires PHP: 7.1 Requires PHP: 7.1
Stable tag: 1.4.16 Stable tag: 1.4.17
License: Apache2.0 License: Apache2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0.html License URI: http://www.apache.org/licenses/LICENSE-2.0.html
@ -76,6 +76,10 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Changelog == == Changelog ==
= 1.4.17 =
- Fix endpoint failed to use https
= 1.4.16 = = 1.4.16 =
- 强制 endpoint 使用 https - 强制 endpoint 使用 https