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