作者 lyh

gx

@@ -444,33 +444,24 @@ if (!function_exists('getFileUrl')) { @@ -444,33 +444,24 @@ if (!function_exists('getFileUrl')) {
444 * @method :post 444 * @method :post
445 * @time :2023/7/20 16:46 445 * @time :2023/7/20 16:46
446 */ 446 */
447 - function getFileUrl($hash){  
448 - if(is_array($hash)){  
449 - foreach ($hash as $v){ 447 + function getFileUrl($path,$location = 1){
  448 + if(is_array($path)){
  449 + foreach ($path as $v){
450 $url[] = getFileUrl($v); 450 $url[] = getFileUrl($v);
451 } 451 }
452 }else{ 452 }else{
453 - $fileModel = new File();  
454 - if (strpos($hash, '.') !== false) {  
455 - $info = $fileModel->read(['path'=>['like','%'.$hash.'%']]);  
456 - }else{  
457 - $info = $fileModel->read(['hash'=>$hash]);  
458 - }  
459 - if(!empty($info)){  
460 - if($info['is_cos'] == 1){ 453 + if($location == 1){
461 $cos = config('filesystems.disks.cos'); 454 $cos = config('filesystems.disks.cos');
462 $cosCdn = $cos['cdn']; 455 $cosCdn = $cos['cdn'];
463 - $url = $cosCdn.$info['path'];  
464 - }else{  
465 - $url = url($info['path']);  
466 - } 456 + $url = $cosCdn.$path;
467 }else{ 457 }else{
468 - $url = $hash; 458 + $url = url($path);
469 } 459 }
470 } 460 }
471 return $url; 461 return $url;
472 } 462 }
473 } 463 }
  464 +
474 /** 465 /**
475 * @remark :字符串截取 466 * @remark :字符串截取
476 * @name :characterTruncation 467 * @name :characterTruncation
@@ -303,7 +303,7 @@ class FileController @@ -303,7 +303,7 @@ class FileController
303 public function responseData($path){ 303 public function responseData($path){
304 $data = [ 304 $data = [
305 'file'=>$path, 305 'file'=>$path,
306 - 'file_link'=>getFileUrl($path), 306 + 'file_link'=>getFileUrl($path,$this->upload_location),
307 ]; 307 ];
308 return $data; 308 return $data;
309 } 309 }