dever 6 سال پیش
والد
کامیت
68e7a8c9be
6فایلهای تغییر یافته به همراه26 افزوده شده و 93 حذف شده
  1. 3 2
      database/file.php
  2. 0 82
      database/streams.php
  3. 6 1
      src/Store/Core.php
  4. 13 2
      src/Store/Handle.php
  5. 1 1
      src/Store/Local.php
  6. 3 5
      src/Store/Qiniu.php

+ 3 - 2
database/file.php

@@ -88,10 +88,10 @@ return array
 			'type' 		=> 'int-11',
 			'name' 		=> '所属资源配置',
 			'default' 	=> '1',
-			'desc' 		=> '分类',
+			'desc' 		=> '所属资源配置',
 			'match' 	=> 'is_numeric',
 			'option' 	=> $upload,
-			'update'	=> 'select',
+			//'update'	=> 'select',
 			'search'	=> 'select',
 			//'control'	=> 'type',
 			//'list'		=> true,
@@ -254,6 +254,7 @@ return array
 			'where' => array
 			(
 				'name' => 'is_string',
+				'upload' => 'yes',
 			),
 			'type' => 'one',
 		),

+ 0 - 82
database/streams.php

@@ -1,82 +0,0 @@
-<?php
-
-return array
-(
-    # 表名
-    'name' => 'streams',
-    # 显示给用户看的名称
-    'lang' => '直播流管理',
-    'order' => 2,
-    # 数据结构
-    'struct' => array
-    (
-    
-        'id'        => array
-        (
-            'type'      => 'int-11',
-            'name'      => 'ID',
-            'default'   => '',
-            'desc'      => '',
-            'match'     => 'is_numeric',
-            'search'    => 'order',
-            //'list'        => true,
-        ),
-
-        'name'      => array
-        (
-            'type'      => 'varchar-300',
-            'name'      => '流名称',
-            'default'   => '',
-            'desc'      => '名称',
-            'match'     => 'option',
-            'update'    => 'text',
-            'list'      => true,
-        ),
-
-        'space'      => array
-        (
-            'type'      => 'varchar-300',
-            'name'      => '空间名',
-            'default'   => '',
-            'desc'      => '空间名',
-            'match'     => 'option',
-            'update'    => 'text',
-            'list'      => true,
-        ),
-
-        'state'     => array
-        (
-            'type'      => 'tinyint-1',
-            'name'      => '状态',
-            'default'   => '1',
-            'desc'      => '请选择状态',
-            'match'     => 'is_numeric',
-        ),
-        
-        'cdate'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '创建时间',
-            'match'     => array('is_numeric', time()),
-            'desc'      => '',
-            # 只有insert时才生效
-            'insert'    => true,
-            //'search'  => 'date',
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
-        ),
-    ),
-
-    'manage' => array
-    (
-        //'excel'   => true,
-        //'delete' => false,
-        //'edit' => false,
-        //'insert' => false,
-    ),
-
-    'request' => array
-    (
-        
-    )
-
-);

+ 6 - 1
src/Store/Core.php

@@ -212,7 +212,7 @@ class Core
 		$this->check(array('handle', 'file', 'key', 'type', 'size'));
 
 		if ($this->output['status'] == -1) {
-			unlink($this->data['file']['tmp_name']);
+			$this->delete();
 			return $this->output;
 		}
 		
@@ -327,6 +327,11 @@ class Core
 		return $ext;
 	}
 
+	public function delete()
+	{
+		unlink($this->data['file']['tmp_name']);
+	}
+
 	/**
 	 * 根据mime类型获取文件扩展名
 	 * 

+ 13 - 2
src/Store/Handle.php

@@ -12,13 +12,14 @@ class Handle
      */
     public function __construct($data = array())
     {
+        $this->yun = $this->local = false;
         $config = Dever::db('upload/upload')->one($data['key']);
 
         $this->save_type = $config['save_type'];
 
-        $this->yun = $config['yun'];
+        $yun = $config['yun'];
         if ($this->save_type >= 2) {
-            if ($this->yun == 1) {
+            if ($yun == 1) {
                 $yun = 'Upload\Src\Store\Qiniu';
             }
             
@@ -38,9 +39,19 @@ class Handle
             $local = $this->local->copy();
         }
 
+        if ($local && $local['status'] == -1) {
+            return $local;
+        }
+
         if ($this->save_type >= 2) {
             $yun = $this->yun->copy();
         }
+
+        if ($this->local) {
+            $this->local->delete();
+        } elseif ($this->yun) {
+            $this->yun->delete();
+        }
         
 
         if ($this->save_type <= 2) {

+ 1 - 1
src/Store/Local.php

@@ -27,7 +27,7 @@ class Local extends Core implements Config
 				// . microtime() . rand(0,1000)
 				$this->name($this->output['file'] . '_' . microtime() . '_' . rand(0,1000))->file();
 			} else {
-				$file = Dever::load('upload/file-name', array('where_name' => $this->name));
+				$file = Dever::load('upload/file-name', array('where_name' => $this->name, 'where_upload' => $this->data['key'], 'rand' => time()));
 			}
 
 			if (!$this->limit) {

+ 3 - 5
src/Store/Qiniu.php

@@ -36,14 +36,14 @@ class Qiniu extends Core implements Config
 
         if (isset($ret['hash']) && isset($ret['key']) && $ret['key'] == $this->file) {
 
-            $file = Dever::load('upload/file-name', array('where_name' => $this->name));
+            $file = Dever::load('upload/file-name', array('where_name' => $this->name, 'where_upload' => $this->data['key'], 'rand' => time()));
             
             if (!$this->limit) {
                 //$this->limit = getimagesize($this->output['file']);
             }
 
-            if (!$this->size) {
-                //$this->size = filesize($this->output['file']);
+            if (!$this->size && isset($this->data['file']['size'])) {
+                $this->size = $this->data['file']['size'];
             }
             
             if (isset($file) && $file) {
@@ -52,8 +52,6 @@ class Qiniu extends Core implements Config
             } else {
                 $this->insert();
             }
-            
-            unlink($this->data['file']['tmp_name']);
 
             return $this->output['url'];
         }