合并分支 'lyh-server' 到 'master'
同步图片修改 查看合并请求 !2663
正在显示
1 个修改的文件
包含
9 行增加
和
38 行删除
| @@ -34,10 +34,8 @@ class SyncImageFileJob implements ShouldQueue | @@ -34,10 +34,8 @@ class SyncImageFileJob implements ShouldQueue | ||
| 34 | */ | 34 | */ |
| 35 | public function handle() | 35 | public function handle() |
| 36 | { | 36 | { |
| 37 | - $file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']); | ||
| 38 | - $cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php'; | ||
| 39 | - echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL; | ||
| 40 | - $code = shell_exec($cmd); | 37 | + $code = $this->synchronizationFile($this->param['path'].'/'.$this->param['name']); |
| 38 | + echo date('Y-m-d H:i:s') . ' | ' . $code . PHP_EOL; | ||
| 41 | if(200 != (int)$code){ | 39 | if(200 != (int)$code){ |
| 42 | $errorFileModel = new ErrorFile(); | 40 | $errorFileModel = new ErrorFile(); |
| 43 | $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]); | 41 | $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]); |
| @@ -45,39 +43,12 @@ class SyncImageFileJob implements ShouldQueue | @@ -45,39 +43,12 @@ class SyncImageFileJob implements ShouldQueue | ||
| 45 | return true; | 43 | return true; |
| 46 | } | 44 | } |
| 47 | 45 | ||
| 48 | - /** | ||
| 49 | - * @remark :获取图片文件链接 | ||
| 50 | - * @name :getUrl | ||
| 51 | - * @author :lyh | ||
| 52 | - * @method :post | ||
| 53 | - * @time :2024/5/22 11:53 | ||
| 54 | - */ | ||
| 55 | - public function getUrl($path,$storage_type,$location){ | ||
| 56 | - if(is_array($path)){ | ||
| 57 | - $url =[]; | ||
| 58 | - foreach ($path as $v){ | ||
| 59 | - $url[] = $this->getUrl($v,$storage_type,$location); | ||
| 60 | - } | ||
| 61 | - }else{ | ||
| 62 | - if(empty($path)){ | ||
| 63 | - return ''; | ||
| 64 | - } | ||
| 65 | - if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){ | ||
| 66 | - return $path; | ||
| 67 | - } | ||
| 68 | - if(substr($path,0,2) == '//'){ | ||
| 69 | - return 'https:'.$path; | ||
| 70 | - } | ||
| 71 | - if($location == 0){ | ||
| 72 | - $cos = config('filesystems.disks.cos'); | ||
| 73 | - $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1']; | ||
| 74 | - $url = $cosCdn.$path; | ||
| 75 | - }else{ | ||
| 76 | - $s3 = config('filesystems.disks.s3'); | ||
| 77 | - $cdn = $s3['cdn']; | ||
| 78 | - $url = $cdn.$path; | ||
| 79 | - } | ||
| 80 | - } | ||
| 81 | - return $url; | 46 | + public function synchronizationFile($path_name){ |
| 47 | + //同步到大文件 | ||
| 48 | + $file_path = config('filesystems.disks.cos')['cdn1'].$path_name; | ||
| 49 | + $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME); | ||
| 50 | + $cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php'; | ||
| 51 | + echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL; | ||
| 52 | + return shell_exec($cmd); | ||
| 82 | } | 53 | } |
| 83 | } | 54 | } |
-
请 注册 或 登录 后发表评论