作者 lyh

gx

... ... @@ -456,7 +456,7 @@ if (!function_exists('getImageUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getImageUrl($path,$location = 1,$storage_type = 0){
function getImageUrl($path,$location = 0,$storage_type = 0){
if(is_array($path)){
$url =[];
foreach ($path as $v){
... ... @@ -472,7 +472,7 @@ if (!function_exists('getImageUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 1){
if($location == 0){
$cos = ($storage_type == 0) ? config('filesystems.disks.cos') : config('filesystems.disks.cos1');
$cosCdn = $cos['cdn'];
$url = $cosCdn.$path;
... ... @@ -492,7 +492,7 @@ if (!function_exists('getFileUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getFileUrl($path,$location = 1,$storage_type = 0){
function getFileUrl($path,$location = 0,$storage_type = 0){
if(is_array($path)){
$url =[];
foreach ($path as $v){
... ... @@ -508,7 +508,7 @@ if (!function_exists('getFileUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 1){
if($location == 0){
$cos = ($storage_type == 0) ? config('filesystems.disks.cos') : config('filesystems.disks.cos1');
$cosCdn = $cos['cdn'];
$url = $cosCdn.$path;
... ...
... ... @@ -121,7 +121,7 @@ class FileController
$url = $this->config['root'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
//同步数据到cos
if($this->upload_location == 1){
if($this->upload_location == 0){
$cosService = new CosService();
$cosService->uploadFile($files,$this->path,$fileName);
}else{
... ... @@ -234,7 +234,7 @@ class FileController
$file_type = $file->getClientOriginalExtension();
$fileName = uniqid().rand(10000,99999).'.'.$file_type;
//同步数据到cos
if($this->upload_location == 1){
if($this->upload_location == 0){
$cosService = new CosService();
$cosService->uploadFile($files,$this->path,$fileName);
}else{
... ... @@ -313,7 +313,7 @@ class FileController
$projectModel = new Project();
$project_info = $projectModel->read(['id' => $this->cache['project_id']], ['project_location']);
if ($project_info['project_location'] != 0) {//通项目时 上传到cos
$this->upload_location = 0;//1:上传到本地
$this->upload_location = 1;//1:上传到本地
}
}
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
... ... @@ -335,7 +335,7 @@ class FileController
$fileModel = new File();
$lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']);
foreach ($lists as $k => $v){
$v['file_link'] = getFileUrl($v['path'],$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0);
$v['file_link'] = getFileUrl($v['path'],$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0);
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -351,7 +351,7 @@ class FileController
public function responseData($path, $name){
$data = [
'file'=>$path,
'file_link'=>getFileUrl($path,$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0),
'file_link'=>getFileUrl($path,$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0),
'name'=>$name,
'file_download'=>url('a/download_files?path='.$path)
];
... ...
... ... @@ -200,7 +200,7 @@ class ImageController extends Controller
}
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//上传到cos
if($this->upload_location == 1){
if($this->upload_location == 0){
$cosService = new CosService();
$cosService->uploadFile($files,$this->path,$fileName);
}else{
... ... @@ -278,7 +278,7 @@ class ImageController extends Controller
$image_type = $file->getClientOriginalExtension();
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//同步数据到cos
if($this->upload_location == 1){
if($this->upload_location == 0){
$cosService = new CosService();
$cosService->uploadFile($file,$this->path,$fileName);
}else{
... ... @@ -359,7 +359,7 @@ class ImageController extends Controller
$lists = $imageModel->lists($this->map,$this->page,$this->row);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image_link'] = getImageUrl($v['path'],$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0);
$v['image_link'] = getImageUrl($v['path'],$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0);
$lists['list'][$k] = $v;
}
}
... ... @@ -408,7 +408,7 @@ class ImageController extends Controller
$projectModel = new Project();
$project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']);
if ($project_info['project_location'] != 0) {//危险项目时 上传到本地
$this->upload_location = 0;//上传到cos
$this->upload_location = 1;//上传到本地
}
}
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
... ... @@ -425,7 +425,7 @@ class ImageController extends Controller
public function responseData($path = '', $name = ''){
$data = [
'image'=>$path,
'image_link'=>getImageUrl($path,$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0),
'image_link'=>getImageUrl($path,$this->cache['project_location'] ?? 0,$this->cache['storage_type'] ?? 0),
'name'=>$name,
'image_download'=>url('a/download_images?path='.$path)
];
... ...