|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :SyncProjectFile.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/18 14:53
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Console\Commands\Test;
|
|
|
|
|
|
|
|
use App\Models\File\ErrorFile;
|
|
|
|
use App\Models\File\File;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
class SyncProjectFile extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'sync_project_file {project_id}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '同步图片与文件';
|
|
|
|
|
|
|
|
|
|
|
|
public function handle(){
|
|
|
|
$project_id = $this->argument('project_id');
|
|
|
|
$fileModel = new File();
|
|
|
|
$lists = $fileModel->list(['project_id'=>$project_id]);//未同步成功的图片及文件
|
|
|
|
foreach ($lists as $k => $v){
|
|
|
|
if(strpos($v['path'], '/181/') !== false ){
|
|
|
|
$code = $this->synchronizationFiles($v['path']);
|
|
|
|
}else{
|
|
|
|
$code = $this->synchronizationFile($v['path']);
|
|
|
|
}
|
|
|
|
if((int)$code == 200){
|
|
|
|
echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :指定同步文件到獨立177服務器
|
|
|
|
* @name :synchronizationFile
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/4/8 11:10
|
|
|
|
*/
|
|
|
|
public function synchronizationFile($path_name){
|
|
|
|
//同步到大文件
|
|
|
|
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
|
|
|
|
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
|
|
|
|
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
|
|
|
|
return shell_exec($cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function synchronizationFiles($path_name){
|
|
|
|
//同步到大文件
|
|
|
|
$file_path = config('filesystems.disks.s3')['cdn'].$path_name;
|
|
|
|
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
|
|
|
|
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
|
|
|
|
return shell_exec($cmd);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|