作者 lyh

gx

@@ -210,10 +210,25 @@ class ImageController extends Controller @@ -210,10 +210,25 @@ class ImageController extends Controller
210 $amazonS3Service->uploadFiles($files,$this->path,$fileName); 210 $amazonS3Service->uploadFiles($files,$this->path,$fileName);
211 } 211 }
212 $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name); 212 $this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
  213 + $this->synchronizationImage($fileName);
213 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name)); 214 return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
214 } 215 }
215 216
216 /** 217 /**
  218 + * @remark :指定同步文件到獨立177服務器
  219 + * @name :synchronizationFile
  220 + * @author :lyh
  221 + * @method :post
  222 + * @time :2024/4/8 11:10
  223 + */
  224 + public function synchronizationImage($fileName){
  225 + //同步到大文件
  226 + $file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
  227 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
  228 + shell_exec($cmd);
  229 + }
  230 +
  231 + /**
217 * @remark :保存数据库 232 * @remark :保存数据库
218 * @name :saveMysql 233 * @name :saveMysql
219 * @author :lyh 234 * @author :lyh
@@ -290,6 +305,7 @@ class ImageController extends Controller @@ -290,6 +305,7 @@ class ImageController extends Controller
290 } 305 }
291 //批量存储 306 //批量存储
292 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); 307 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
  308 + $this->synchronizationImage($fileName);
293 $data[] = $this->responseData($this->path.'/'.$fileName,$name); 309 $data[] = $this->responseData($this->path.'/'.$fileName,$name);
294 } 310 }
295 $this->response('图片资源',Code::SUCCESS,$data); 311 $this->response('图片资源',Code::SUCCESS,$data);