SyncTimeFiles.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @remark :
* @name :SyncTimeFiles.php
* @author :lyh
* @method :post
* @time :2024/8/14 14:23
*/
namespace App\Console\Commands\SyncFilesImage;
use App\Models\File\File;
use App\Models\File\Image;
use Illuminate\Console\Command;
class SyncTimeFiles extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_videos';
/**
* The console command description.
*
* @var string
*/
protected $description = '按时间同步图片与文件';
public function handle()
{
// $fileModel = new File();
$imagesModel = new Image();
// $start = '2025-10-14 00:00:00';
$start = '2025-10-18 00:00:00';
$end = '2025-10-31 23:59:59';
$lists = $imagesModel->list(['created_at'=>['between',[$start,$end]]],'id',['path'],'asc');
foreach ($lists as $v){
$path = $v['path'];
echo date('Y-m-d H:i:s') . ' | 图片链接:' . $path . PHP_EOL;
$code = $this->synchronizationFile($path);
echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
}
return true;
}
public function synchronizationFile($path_name){
//同步到大文件
$cmd = 'curl -k -F "file_path='.$path_name.'" -F "save_path=/www/wwwroot/cos'.$path_name.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
}