|
@@ -207,8 +207,9 @@ class ImageController extends Controller |
|
@@ -207,8 +207,9 @@ class ImageController extends Controller |
|
207
|
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
|
207
|
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
|
|
208
|
//上传到cos
|
208
|
//上传到cos
|
|
209
|
if($this->upload_location == 0){
|
209
|
if($this->upload_location == 0){
|
|
|
|
210
|
+ $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
|
|
210
|
$cosService = new CosService();
|
211
|
$cosService = new CosService();
|
|
211
|
- $cosService->uploadFile($files,$this->path,$fileName);
|
212
|
+ $cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions);
|
|
212
|
}else{
|
213
|
}else{
|
|
213
|
//TODO::上传亚马逊
|
214
|
//TODO::上传亚马逊
|
|
214
|
$amazonS3Service = new AmazonS3Service();
|
215
|
$amazonS3Service = new AmazonS3Service();
|
|
@@ -342,7 +343,7 @@ class ImageController extends Controller |
|
@@ -342,7 +343,7 @@ class ImageController extends Controller |
|
342
|
if($this->upload_location == 0){
|
343
|
if($this->upload_location == 0){
|
|
343
|
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
|
344
|
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
|
|
344
|
$cosService = new CosService();
|
345
|
$cosService = new CosService();
|
|
345
|
- $cosService->uploadFile($file,$this->path,$fileName,$watermarkOptions);
|
346
|
+ $cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions);
|
|
346
|
}else{
|
347
|
}else{
|
|
347
|
//TODO::上传亚马逊
|
348
|
//TODO::上传亚马逊
|
|
348
|
$amazonS3Service = new AmazonS3Service();
|
349
|
$amazonS3Service = new AmazonS3Service();
|
|
@@ -365,37 +366,44 @@ class ImageController extends Controller |
|
@@ -365,37 +366,44 @@ class ImageController extends Controller |
|
365
|
* @time :2024/8/24 11:03
|
366
|
* @time :2024/8/24 11:03
|
|
366
|
*/
|
367
|
*/
|
|
367
|
public function getProjectConfig($project_id = 0){
|
368
|
public function getProjectConfig($project_id = 0){
|
|
|
|
369
|
+ $str = '';
|
|
368
|
$imageSettingModel = new ImageSetting();
|
370
|
$imageSettingModel = new ImageSetting();
|
|
369
|
$settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
|
371
|
$settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
|
|
370
|
if($settingInfo !== false){
|
372
|
if($settingInfo !== false){
|
|
371
|
if($settingInfo['status'] == 1 && !empty($settingInfo['image_data'])){
|
373
|
if($settingInfo['status'] == 1 && !empty($settingInfo['image_data'])){
|
|
372
|
$image_data = json_decode($settingInfo['image_data'],true);
|
374
|
$image_data = json_decode($settingInfo['image_data'],true);
|
|
373
|
foreach ($image_data as $k => $v){
|
375
|
foreach ($image_data as $k => $v){
|
|
374
|
- $arr = implode('/',$v);
|
|
|
|
375
|
- if ($arr[0] == 'image') {
|
|
|
|
376
|
- $arr[1] = urlSafeBase64Encode($arr[1]);
|
376
|
+ if (str_starts_with($v, "image/")) {
|
|
|
|
377
|
+ $v = 'image/'.urlSafeBase64Encode(substr($v, strlen("image/")));
|
|
377
|
}
|
378
|
}
|
|
378
|
$image_data[$k] = $v;
|
379
|
$image_data[$k] = $v;
|
|
379
|
}
|
380
|
}
|
|
|
|
381
|
+ $str = 'watermark/1/'.implode('/',$image_data);
|
|
|
|
382
|
+ return $str;
|
|
380
|
}
|
383
|
}
|
|
381
|
if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
|
384
|
if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
|
|
382
|
$str_data = json_decode($settingInfo['str_data'],true);
|
385
|
$str_data = json_decode($settingInfo['str_data'],true);
|
|
383
|
foreach ($str_data as $k => $v){
|
386
|
foreach ($str_data as $k => $v){
|
|
384
|
- $arr = implode('/',$v);
|
387
|
+ $arr = explode('/',$v);
|
|
385
|
if ($arr[0] == 'text') {
|
388
|
if ($arr[0] == 'text') {
|
|
386
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
389
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
|
|
|
390
|
+ $v = implode('/',$arr);
|
|
387
|
}
|
391
|
}
|
|
388
|
if ($arr[0] == 'font') {
|
392
|
if ($arr[0] == 'font') {
|
|
389
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
393
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
|
|
|
394
|
+ $v = implode('/',$arr);
|
|
390
|
}
|
395
|
}
|
|
391
|
if ($arr[0] == 'fill') {
|
396
|
if ($arr[0] == 'fill') {
|
|
392
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
397
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
|
|
|
398
|
+ $v = implode('/',$arr);
|
|
393
|
}
|
399
|
}
|
|
394
|
- $str_data[$k] = $arr;
|
400
|
+ $str_data[$k] = $v;
|
|
395
|
}
|
401
|
}
|
|
396
|
}
|
402
|
}
|
|
|
|
403
|
+ $str = 'watermark/2/'.implode('/',$str_data);
|
|
|
|
404
|
+ return $str;
|
|
397
|
}
|
405
|
}
|
|
398
|
- return null;
|
406
|
+ return $str;
|
|
399
|
}
|
407
|
}
|
|
400
|
|
408
|
|
|
401
|
/**
|
409
|
/**
|
|
@@ -726,10 +734,10 @@ class ImageController extends Controller |
|
@@ -726,10 +734,10 @@ class ImageController extends Controller |
|
726
|
if($info === false){
|
734
|
if($info === false){
|
|
727
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
735
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
|
728
|
}
|
736
|
}
|
|
729
|
- if($info['status'] == 1 && !empty($info['image_data'])){
|
737
|
+ if($info['status'] == 1 && empty($info['image_data'])){
|
|
730
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
738
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
|
731
|
}
|
739
|
}
|
|
732
|
- if($info['status'] == 2 && !empty($info['str_data'])){
|
740
|
+ if($info['status'] == 2 && empty($info['str_data'])){
|
|
733
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
741
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
|
734
|
}
|
742
|
}
|
|
735
|
$imageSetting->edit(['status'=>$this->param['status']],['project_id'=>$this->cache['project_id']]);
|
743
|
$imageSetting->edit(['status'=>$this->param['status']],['project_id'=>$this->cache['project_id']]);
|
|
@@ -753,7 +761,9 @@ class ImageController extends Controller |
|
@@ -753,7 +761,9 @@ class ImageController extends Controller |
|
753
|
if(!empty($info['str_data'])){
|
761
|
if(!empty($info['str_data'])){
|
|
754
|
$info['str_data'] = json_decode($info['str_data'],true);
|
762
|
$info['str_data'] = json_decode($info['str_data'],true);
|
|
755
|
}
|
763
|
}
|
|
|
|
764
|
+ $info['domain'] = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';
|
|
756
|
}
|
765
|
}
|
|
|
|
766
|
+
|
|
757
|
$this->response('success',Code::SUCCESS,$info);
|
767
|
$this->response('success',Code::SUCCESS,$info);
|
|
758
|
}
|
768
|
}
|
|
759
|
} |
769
|
} |