|
@@ -37,55 +37,23 @@ class SyncTimeFiles extends Command |
|
@@ -37,55 +37,23 @@ class SyncTimeFiles extends Command |
|
37
|
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
|
37
|
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
|
|
38
|
foreach ($lists as $v){
|
38
|
foreach ($lists as $v){
|
|
39
|
$path = $v['path'];
|
39
|
$path = $v['path'];
|
|
40
|
- $this->param['name'] = basename($path);
|
|
|
|
41
|
- $this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
|
|
|
|
42
|
- $file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
|
|
|
|
43
|
- $cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
|
|
|
|
44
|
- echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
|
|
|
|
45
|
- $code = shell_exec($cmd);
|
40
|
+ $code = $this->synchronizationFile($path);
|
|
46
|
if(200 != (int)$code){
|
41
|
if(200 != (int)$code){
|
|
47
|
echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
|
42
|
echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
|
|
48
|
-// $errorFileModel = new ErrorFile();
|
|
|
|
49
|
-// $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
|
43
|
+ $errorFileModel = new ErrorFile();
|
|
|
|
44
|
+ $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
|
|
50
|
}
|
45
|
}
|
|
51
|
echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
|
46
|
echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
|
|
52
|
}
|
47
|
}
|
|
53
|
return true;
|
48
|
return true;
|
|
54
|
}
|
49
|
}
|
|
55
|
|
50
|
|
|
56
|
- /**
|
|
|
|
57
|
- * @remark :获取图片文件链接
|
|
|
|
58
|
- * @name :getUrl
|
|
|
|
59
|
- * @author :lyh
|
|
|
|
60
|
- * @method :post
|
|
|
|
61
|
- * @time :2024/5/22 11:53
|
|
|
|
62
|
- */
|
|
|
|
63
|
- public function getUrl($path,$storage_type,$location){
|
|
|
|
64
|
- if(is_array($path)){
|
|
|
|
65
|
- $url =[];
|
|
|
|
66
|
- foreach ($path as $v){
|
|
|
|
67
|
- $url[] = $this->getUrl($v,$storage_type,$location);
|
|
|
|
68
|
- }
|
|
|
|
69
|
- }else{
|
|
|
|
70
|
- if(empty($path)){
|
|
|
|
71
|
- return '';
|
|
|
|
72
|
- }
|
|
|
|
73
|
- if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
|
|
|
|
74
|
- return $path;
|
|
|
|
75
|
- }
|
|
|
|
76
|
- if(substr($path,0,2) == '//'){
|
|
|
|
77
|
- return 'https:'.$path;
|
|
|
|
78
|
- }
|
|
|
|
79
|
- if($location == 0){
|
|
|
|
80
|
- $cos = config('filesystems.disks.cos');
|
|
|
|
81
|
- $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
|
|
|
|
82
|
- $url = $cosCdn.$path;
|
|
|
|
83
|
- }else{
|
|
|
|
84
|
- $s3 = config('filesystems.disks.s3');
|
|
|
|
85
|
- $cdn = $s3['cdn'];
|
|
|
|
86
|
- $url = $cdn.$path;
|
|
|
|
87
|
- }
|
|
|
|
88
|
- }
|
|
|
|
89
|
- return $url;
|
51
|
+ public function synchronizationFile($path_name){
|
|
|
|
52
|
+ //同步到大文件
|
|
|
|
53
|
+ $file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
|
|
|
|
54
|
+ $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
|
|
|
|
55
|
+ $cmd = 'curl -k -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
|
|
|
|
56
|
+ return shell_exec($cmd);
|
|
90
|
}
|
57
|
}
|
|
|
|
58
|
+
|
|
91
|
} |
59
|
} |