|
@@ -12,6 +12,34 @@ use Upload\Src\Lib\Img;
|
|
|
|
|
|
class View
|
|
|
{
|
|
|
+ public function token()
|
|
|
+ {
|
|
|
+ $key = Dever::input('key');
|
|
|
+ $upload = Dever::db('upload/upload')->one($key);
|
|
|
+ if (!$upload) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Dever::apply('sdk/qiniu', 'upload');
|
|
|
+ $config = Dever::db('upload/yun')->one($upload['yun']);
|
|
|
+ $accessKey = $config['appkey'];
|
|
|
+ $secretKey = $config['appsecret'];
|
|
|
+ $this->host = $config['host'];
|
|
|
+ $auth = new \Qiniu\Auth($accessKey, $secretKey);
|
|
|
+ $bucket = $this->config['bucket'];
|
|
|
+
|
|
|
+ $policy = array(
|
|
|
+ 'callbackUrl' => 'http://your.domain.com/upload_verify_callback.php',
|
|
|
+ 'callbackBody' => 'filename=$(fname)&filesize=$(fsize)'
|
|
|
+ );
|
|
|
+
|
|
|
+ // 生成上传Token
|
|
|
+ $token = $auth->uploadToken($bucket, null, 3600);
|
|
|
+
|
|
|
+ $ret = array('uptoken' => $token);
|
|
|
+
|
|
|
+ echo json_encode($ret);die;
|
|
|
+ }
|
|
|
+
|
|
|
public function files()
|
|
|
{
|
|
|
$data = array();
|