作者 lyh

gx

@@ -134,7 +134,7 @@ class FileController @@ -134,7 +134,7 @@ class FileController
134 $amazonS3Service->uploadFiles($files,$this->path,$fileName); 134 $amazonS3Service->uploadFiles($files,$this->path,$fileName);
135 } 135 }
136 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name); 136 $this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
137 - $this->synchronizationFile($fileName); 137 + $this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
138 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 138 $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
139 } 139 }
140 140
@@ -145,9 +145,9 @@ class FileController @@ -145,9 +145,9 @@ class FileController
145 * @method :post 145 * @method :post
146 * @time :2024/4/8 11:10 146 * @time :2024/4/8 11:10
147 */ 147 */
148 - public function synchronizationFile($fileName){ 148 + public function synchronizationFile($fileName,$location){
149 //同步到大文件 149 //同步到大文件
150 - SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]); 150 + SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
151 return true; 151 return true;
152 } 152 }
153 153
@@ -303,7 +303,7 @@ class FileController @@ -303,7 +303,7 @@ class FileController
303 $mime = $file->getMimeType(); 303 $mime = $file->getMimeType();
304 $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name); 304 $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
305 $data[] = $this->responseData($this->path.'/'.$fileName, $name); 305 $data[] = $this->responseData($this->path.'/'.$fileName, $name);
306 - $this->synchronizationFile($fileName); 306 + $this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
307 } 307 }
308 $this->response('资源',Code::SUCCESS,$data); 308 $this->response('资源',Code::SUCCESS,$data);
309 } 309 }
@@ -41,7 +41,7 @@ class ImageController extends Controller @@ -41,7 +41,7 @@ class ImageController extends Controller
41 41
42 42
43 43
44 - public $upload_location = 0;//同步到cos 44 + public $upload_location = 0;//1:上传到cos
45 //上传图片类型 45 //上传图片类型
46 public $image_type = [ 46 public $image_type = [
47 1 => 'image_product', 47 1 => 'image_product',
@@ -215,7 +215,7 @@ class ImageController extends Controller @@ -215,7 +215,7 @@ class ImageController extends Controller
215 $amazonS3Service->uploadFiles($files,$this->path,$fileName); 215 $amazonS3Service->uploadFiles($files,$this->path,$fileName);
216 } 216 }
217 $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name); 217 $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
218 - $this->synchronizationImage($fileName); 218 + $this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
219 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 219 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
220 } 220 }
221 221
@@ -264,8 +264,8 @@ class ImageController extends Controller @@ -264,8 +264,8 @@ class ImageController extends Controller
264 * @method :post 264 * @method :post
265 * @time :2024/4/8 11:10 265 * @time :2024/4/8 11:10
266 */ 266 */
267 - public function synchronizationImage($fileName){  
268 - SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]); 267 + public function synchronizationImage($fileName,$location){
  268 + SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
269 return true; 269 return true;
270 } 270 }
271 271
@@ -347,7 +347,7 @@ class ImageController extends Controller @@ -347,7 +347,7 @@ class ImageController extends Controller
347 } 347 }
348 //批量存储 348 //批量存储
349 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); 349 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
350 - $this->synchronizationImage($fileName); 350 + $this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
351 $data[] = $this->responseData($this->path.'/'.$fileName,$name); 351 $data[] = $this->responseData($this->path.'/'.$fileName,$name);
352 } 352 }
353 $this->response('图片资源',Code::SUCCESS,$data); 353 $this->response('图片资源',Code::SUCCESS,$data);
@@ -472,8 +472,9 @@ class ImageController extends Controller @@ -472,8 +472,9 @@ class ImageController extends Controller
472 //根据项目上传标识区分上传到cos/本地 472 //根据项目上传标识区分上传到cos/本地
473 $projectModel = new Project(); 473 $projectModel = new Project();
474 $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']); 474 $project_info = $projectModel->read(['id'=>$this->cache['project_id']],['project_location']);
475 - if ($project_info['project_location'] != 0) {//危险项目时 上传到本地  
476 - $this->upload_location = 1;//上传到本地 475 + if ($project_info['project_location'] != 0) {
  476 + //TODO::危险项目时
  477 + $this->upload_location = 1;//上传到cos
477 } 478 }
478 } 479 }
479 $this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); 480 $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 @@ -38,7 +38,7 @@ class SyncImageFileJob implements ShouldQueue
38 */ 38 */
39 public function handle() 39 public function handle()
40 { 40 {
41 - $file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0); 41 + $file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']);
42 $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php'; 42 $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
43 $code = shell_exec($cmd); 43 $code = shell_exec($cmd);
44 if(200 != (int)$code){ 44 if(200 != (int)$code){