Skip to content

Commit

Permalink
QNUpload v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rakiy committed Dec 9, 2016
1 parent 22a6104 commit 30c22d6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
23 changes: 16 additions & 7 deletions QNUpload/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* 七牛附件上传 更新至1.2.0,适用于typecho 1.0,七牛SDK提升至6.1.13
* 七牛云附件上传
*
* @package QNUpload
* @author rakiy
* @version 1.2.0
* @version 1.3.0
* @link http://ysido.com
* @date 2016-11-28
* @date 2016-12-09
*/

class QNUpload_Plugin implements Typecho_Plugin_Interface
Expand Down Expand Up @@ -67,10 +67,18 @@ public static function config(Typecho_Widget_Helper_Form $form){
_t(''));
$form->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);
}

Expand Down Expand Up @@ -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),
);
}
/**
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 24 additions & 4 deletions QNUpload/Qiniu/conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<Please apply your access key>';
$QINIU_SECRET_KEY = '<Dont send your secret key to anyone>';
12 changes: 11 additions & 1 deletion QNUpload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,同时简化了上传方法
Expand Down

0 comments on commit 30c22d6

Please sign in to comment.