SyncTimeFiles.php 1.4 KB
<?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);
    }

}