dever 4 년 전
부모
커밋
28c53b81fd
1개의 변경된 파일28개의 추가작업 그리고 1개의 파일을 삭제
  1. 28 1
      lib/File.php

+ 28 - 1
lib/File.php

@@ -8,6 +8,33 @@ class File
 	# 获取文件内容
 	public function content($file)
 	{
-		
+		if (strstr($file, '{uploadYun}')) {
+            $file = str_replace('{uploadYun}', '', $file);
+        } elseif (strstr($file, 'http')) {
+            $host = parse_url($file);
+            $file = $host['path'];
+        }
+
+        $temp = explode('/', $file);
+        $key = $temp[1];
+        $config = Dever::load('upload/lib/config')->get($key);
+        if ($config) {
+            if ($config['save_type'] >= 2 && $config['yun']) {
+                if ($config['yun']['type'] == 2) {
+                    $class = 'Upload\Lib\View\Qiniu';
+                } elseif ($config['yun']['type'] == 1) {
+                    $class = 'Upload\Lib\View\Oss';
+                }
+                $data['host'] = $config['yun']['host'];
+                
+                $yun = new $class();
+                $file = $yun->connect($config['yun'], $config)->download($config['bucket'], $file);
+            } else {
+                $file = Dever::local($file);
+                $file = file_get_contents($file);
+            }
+        }
+
+        return $file;
 	}
 }