Fix errors when uploading PDF and other file formats

pull/25/head v1.4.6
sy-records 2023-10-19 10:35:23 +08:00
parent 48df76994b
commit 6c09f4057e
No known key found for this signature in database
GPG Key ID: C3BB4FF13CD72ACE
2 changed files with 22 additions and 16 deletions

View File

@ -3,7 +3,7 @@
Plugin Name: OSS Aliyun
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.
Version: 1.4.4
Version: 1.4.6
Author: 沈唁
Author URI: https://qq52o.me
License: Apache2.0
@ -20,7 +20,7 @@ use OSS\Credentials\CredentialsProvider;
use AlibabaCloud\Credentials\Credential;
use OSS\Credentials\StaticCredentialsProvider;
define('OSS_VERSION', '1.4.4');
define('OSS_VERSION', '1.4.6');
define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__)));
if (!function_exists('get_home_path')) {
@ -251,6 +251,10 @@ function oss_upload_attachments($metadata)
*/
function oss_upload_thumbs($metadata)
{
if (empty($metadata['file'])) {
return $metadata;
}
//获取上传路径
$wp_uploads = wp_upload_dir();
$basedir = $wp_uploads['basedir'];
@ -261,7 +265,6 @@ function oss_upload_thumbs($metadata)
$no_local_file = esc_attr($oss_options['nolocalsaving']) == 'true';
$no_thumb = esc_attr($oss_options['nothumb']) == 'true';
if (!empty($metadata['file'])) {
// Maybe there is a problem with the old version
$file = $basedir . '/' . $metadata['file'];
if ($upload_path != '.') {
@ -275,7 +278,6 @@ function oss_upload_thumbs($metadata)
}
oss_file_upload($object, $file, $no_local_file);
}
//得到本地文件夹和远端文件夹
$dirname = dirname($metadata['file']);

View File

@ -5,7 +5,7 @@ Tags: oss, 阿里云, 对象存储, aliyun
Requires at least: 4.2
Tested up to: 6.3
Requires PHP: 7.0
Stable tag: 1.4.5
Stable tag: 1.4.6
License: Apache2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0.html
@ -73,6 +73,10 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Changelog ==
= 1.4.6 =
- 修复 pdf 等文件格式上传时报错
= 1.4.5 =
- 兼容 PHP 7.0