From 30c22d688ed91a59344dfafa0b8b8d490811c3aa Mon Sep 17 00:00:00 2001 From: rakiy Date: Fri, 9 Dec 2016 17:06:57 +0800 Subject: [PATCH] QNUpload v1.3.0 --- QNUpload/Plugin.php | 23 ++++++++++++++++------- QNUpload/Qiniu/conf.php | 28 ++++++++++++++++++++++++---- QNUpload/README.md | 12 +++++++++++- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/QNUpload/Plugin.php b/QNUpload/Plugin.php index cb4dcdc1..bb21f4f1 100644 --- a/QNUpload/Plugin.php +++ b/QNUpload/Plugin.php @@ -1,12 +1,12 @@ addInput($bucketName); + $server = new Typecho_Widget_Helper_Form_Element_Radio('server', + array('0'=>_t('华东'), '1'=>_t('华北'), '2'=>_t('华南'), '3'=>_t('北美')), + '0', + _t('选择bucket节点'), + _t('一般在七牛面板右下角显示') + ); + $form->addInput($server); + $domain = new Typecho_Widget_Helper_Form_Element_Text('domain', NULL, 'http://', - _t('绑定的域名,如果你想使用绑定了的域名,请填写,否则请留空'), - _t('')); + _t('使用的域名,必填,请带上http://'), + _t('一般在七牛存储面板右上角,形如 xxx.bkt.clouddn.com/xxx.u.qiniu.com')); $form->addInput($domain); } @@ -112,10 +120,10 @@ public static function uploadHandle($file){ if($err !== null) return false; return array( 'name' => $file['name'], - 'path' => $fileName, + 'path' => $filePath . $fileName, 'size' => $file['size'], 'type' => $ext, - 'mime' => @Typecho_Common::mimeContentType(rtrim($options->domain,'/') . '/' . $fileName), + 'mime' => @Typecho_Common::mimeContentType(rtrim($options->domain,'/') . '/' . $filePath . $fileName), ); } /** @@ -211,6 +219,7 @@ public static function attachmentHandle(array $content){ * @return object */ private static function __qninit__($options){ + $server = intval($options->server); require_once("Qiniu/rs.php"); require_once("Qiniu/io.php"); $accessKey = $options->ak; diff --git a/QNUpload/Qiniu/conf.php b/QNUpload/Qiniu/conf.php index cdc736a5..83c96f06 100644 --- a/QNUpload/Qiniu/conf.php +++ b/QNUpload/Qiniu/conf.php @@ -12,11 +12,31 @@ $SDK_VER = "6.1.13"; -$QINIU_UP_HOST = 'http://upload.qiniu.com'; -$QINIU_RS_HOST = 'http://rs.qbox.me'; -$QINIU_RSF_HOST = 'http://rsf.qbox.me'; + +$QINIU_RS_HOST = 'http://rs.qbox.me'; +$QINIU_RSF_HOST = 'http://rsf.qbox.me'; $QINIU_API_HOST = 'http://api.qiniu.com'; -$QINIU_IOVIP_HOST = 'http://iovip.qbox.me'; + +//华东 +if($server == 0){ + $QINIU_UP_HOST = 'http://up.qiniu.com'; + $QINIU_IOVIP_HOST = 'http://iovip.qbox.me'; +} +//华北 +elseif($server == 1){ + $QINIU_UP_HOST = 'up-z1.qiniu.com'; + $QINIU_IOVIP_HOST = 'http://iovip-z1.qbox.me'; +} +//华南 +elseif($server == 2){ + $QINIU_UP_HOST = 'up-z2.qiniu.com'; + $QINIU_IOVIP_HOST = 'http://iovip-z2.qbox.me'; +} +//北美 +elseif($server == 3){ + $QINIU_UP_HOST = 'up-na0.qiniu.com'; + $QINIU_IOVIP_HOST = 'http://iovip-na0.qbox.me'; +} $QINIU_ACCESS_KEY = ''; $QINIU_SECRET_KEY = ''; diff --git a/QNUpload/README.md b/QNUpload/README.md index d2937c81..d6f35e6b 100644 --- a/QNUpload/README.md +++ b/QNUpload/README.md @@ -2,10 +2,20 @@ **七牛云附件上传** -**版本: v1.2.0** +**版本: v1.3.0** 升级时建议最好卸载旧插件然后再安装,提前备份一下SK,AK,域名,重新启用需要重传 +== 感谢 == + + [@刘世杰](http://t.qq.com/youtubefans),[@雨伤](http://t.qq.com/yushanggj) + +== 更新 2016-12-09 == + + 1. 后台添加选择bucket的位置选项,影响上传接口 + 2. 后台添加域名必填的提示(感谢@雨伤反馈) + 3. 修复后台返回文件不带路径的BUG(感谢@雨伤反馈) + == 更新 2016-11-28 == 1. 将所含七牛SDK升级至6.1.3,同时简化了上传方法