|
...
|
...
|
@@ -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');
|
...
|
...
|
|