作者 lyh

gx

... ... @@ -134,7 +134,7 @@ class FileController
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
$this->synchronizationFile($fileName);
$this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -145,9 +145,9 @@ class FileController
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($fileName){
public function synchronizationFile($fileName,$location){
//同步到大文件
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]);
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
return true;
}
... ... @@ -303,7 +303,7 @@ class FileController
$mime = $file->getMimeType();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
$data[] = $this->responseData($this->path.'/'.$fileName, $name);
$this->synchronizationFile($fileName);
$this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
}
$this->response('资源',Code::SUCCESS,$data);
}
... ...
... ... @@ -41,7 +41,7 @@ class ImageController extends Controller
public $upload_location = 0;//同步到cos
public $upload_location = 0;//1:上传到cos
//上传图片类型
public $image_type = [
1 => 'image_product',
... ... @@ -215,7 +215,7 @@ class ImageController extends Controller
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
$this->synchronizationImage($fileName);
$this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -264,8 +264,8 @@ class ImageController extends Controller
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationImage($fileName){
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]);
public function synchronizationImage($fileName,$location){
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
return true;
}
... ... @@ -347,7 +347,7 @@ class ImageController extends Controller
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$this->synchronizationImage($fileName);
$this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
}
$this->response('图片资源',Code::SUCCESS,$data);
... ... @@ -472,8 +472,9 @@ class ImageController extends Controller
//根据项目上传标识区分上传到cos/本地
$projectModel = new Project();
$project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']);
if ($project_info['project_location'] != 0) {//危险项目时 上传到本地
$this->upload_location = 1;//上传到本地
if ($project_info['project_location'] != 0) {
//TODO::危险项目时
$this->upload_location = 1;//上传到cos
}
}
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
... ...
... ... @@ -38,7 +38,7 @@ class SyncImageFileJob implements ShouldQueue
*/
public function handle()
{
$file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0);
$file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']);
$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){
... ...