作者 lyh

gx

... ... @@ -6,6 +6,8 @@ use App\Enums\Common\Code;
use App\Helper\Translate;
use App\Http\Controllers\Controller;
use App\Http\Controllers\type;
use App\Jobs\CopyProjectJob;
use App\Jobs\SyncImageFileJob;
use App\Models\File\ErrorFile;
use App\Models\File\Image as ImageModel;
use App\Models\Project\Project;
... ... @@ -262,14 +264,14 @@ class ImageController extends Controller
* @time :2024/4/8 11:10
*/
public function synchronizationImage($fileName){
//同步到大文件
$file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->path.'/'.$fileName]);
}
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]);
// $file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
// $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
// $code = shell_exec($cmd);
// if(200 != (int)$code){
// $errorFileModel = new ErrorFile();
// $errorFileModel->add(['path'=>$this->path.'/'.$fileName]);
// }
return true;
}
... ...
<?php
namespace App\Jobs;
use App\Events\CopyImageFile;
use App\Models\File\ErrorFile;
use App\Models\File\File as FileModel;
use App\Models\File\Image as ImageModel;
use App\Services\AmazonS3Service;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SyncImageFileJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3; // 可配置任务重试次数
protected $param;
/**
* Create a new job instance.
*
* @param CopyImageFile $event
* @return void
*/
public function __construct($data)
{
$this->param = $data;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
return true;
}
}
... ...
... ... @@ -60,6 +60,10 @@ class RouteMap extends Base
}
$i=1;
$sign = generateRoute($title);
$length = strlen($sign);
if($length > 100){
$sign = trim(mb_substr($sign, 0, 100, 'UTF-8'),'-');
}
$info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
$suffix = '';
if(empty($info)){
... ...