|
...
|
...
|
@@ -111,7 +111,7 @@ class FileController |
|
|
|
$fileModel = new File();
|
|
|
|
$file_hash = $fileModel->read(['hash'=>$hash]);
|
|
|
|
if($file_hash !== false){
|
|
|
|
return $this->response('资源',Code::SUCCESS,$this->responseData($fileModel,$hash));
|
|
|
|
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path']));
|
|
|
|
}
|
|
|
|
$url = $this->config['root'].$this->path;
|
|
|
|
$fileName = uniqid().rand(10000,99999).'.'.$file_type;
|
|
...
|
...
|
@@ -126,7 +126,7 @@ class FileController |
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
|
|
|
|
return $this->response('资源',Code::SUCCESS,$this->responseData($fileModel,$hash));
|
|
|
|
return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -168,7 +168,7 @@ class FileController |
|
|
|
$hash = hash_file('md5', $file->getPathname());
|
|
|
|
$file_hash = $fileModel->read(['hash'=>$hash]);
|
|
|
|
if($file_hash !== false){
|
|
|
|
$data[] = $this->responseData($fileModel,$hash);
|
|
|
|
$data[] = $this->responseData($file_hash['path']);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$url = $this->config['root'].'/'.$this->path;
|
|
...
|
...
|
@@ -187,7 +187,7 @@ class FileController |
|
|
|
$size = $file->getSize();
|
|
|
|
$mime = $file->getMimeType();
|
|
|
|
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
|
|
|
|
$data[] = $this->responseData($fileModel,$hash);
|
|
|
|
$data[] = $this->responseData($this->path.'/'.$fileName);
|
|
|
|
}
|
|
|
|
$this->response('资源',Code::SUCCESS,$data);
|
|
|
|
}
|
|
...
|
...
|
@@ -274,23 +274,6 @@ class FileController |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取文件链接
|
|
|
|
* @name :getImageUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/20 16:46
|
|
|
|
*/
|
|
|
|
public function getFileUrl(&$fileModel,$hash){
|
|
|
|
$info = $fileModel->read(['hash'=>$hash]);
|
|
|
|
if($info['is_cos'] == 1){
|
|
|
|
$url = getFileUrl($info['hash']);
|
|
|
|
}else{
|
|
|
|
$url = url('a/file/'.$info['hash']);
|
|
|
|
}
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取所有视频
|
|
|
|
* @name :getImageList
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -301,7 +284,7 @@ class FileController |
|
|
|
$fileModel = new File();
|
|
|
|
$lists = $fileModel->list(['refer'=>1],$order = 'id',['id','hash','type','path','created_at']);
|
|
|
|
foreach ($lists as $k => $v){
|
|
|
|
$v['file_link'] = $this->getFileUrl($fileModel,$v['hash']);
|
|
|
|
$v['file_link'] = getFileUrl($v['hash']);
|
|
|
|
$lists[$k] = $v;
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,$lists);
|
|
...
|
...
|
@@ -314,11 +297,10 @@ class FileController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/26 13:41
|
|
|
|
*/
|
|
|
|
public function responseData(&$fileModel,$hash){
|
|
|
|
public function responseData($path){
|
|
|
|
$data = [
|
|
|
|
'file'=>$hash,
|
|
|
|
'file_link'=>$this->getFileUrl($fileModel,$hash),
|
|
|
|
'file_download'=>url('a/download_files?hash='.$hash),
|
|
|
|
'file'=>$path,
|
|
|
|
'file_link'=>getFileUrl($path),
|
|
|
|
];
|
|
|
|
return $data;
|
|
|
|
}
|
...
|
...
|
|