|
...
|
...
|
@@ -207,8 +207,9 @@ class ImageController extends Controller |
|
|
|
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
|
|
|
|
//上传到cos
|
|
|
|
if($this->upload_location == 0){
|
|
|
|
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
|
|
|
|
$cosService = new CosService();
|
|
|
|
$cosService->uploadFile($files,$this->path,$fileName);
|
|
|
|
$cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions);
|
|
|
|
}else{
|
|
|
|
//TODO::上传亚马逊
|
|
|
|
$amazonS3Service = new AmazonS3Service();
|
|
...
|
...
|
@@ -231,6 +232,9 @@ class ImageController extends Controller |
|
|
|
$suffix = array_pop($nameArr) ?? 'jpg';
|
|
|
|
$nameStr = implode('-', $nameArr);
|
|
|
|
$enName = generateRoute(Translate::tran($nameStr, 'en'));
|
|
|
|
if(substr($enName, 0, 1) === '-'){
|
|
|
|
$enName = $nameStr;
|
|
|
|
}
|
|
|
|
$fileName = $enName;
|
|
|
|
$i=1;
|
|
|
|
while($this->onlyName($enName.'.'.$suffix,$project_id)){
|
|
...
|
...
|
@@ -342,7 +346,7 @@ class ImageController extends Controller |
|
|
|
if($this->upload_location == 0){
|
|
|
|
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
|
|
|
|
$cosService = new CosService();
|
|
|
|
$cosService->uploadFile($file,$this->path,$fileName,$watermarkOptions);
|
|
|
|
$cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions);
|
|
|
|
}else{
|
|
|
|
//TODO::上传亚马逊
|
|
|
|
$amazonS3Service = new AmazonS3Service();
|
|
...
|
...
|
@@ -365,37 +369,44 @@ class ImageController extends Controller |
|
|
|
* @time :2024/8/24 11:03
|
|
|
|
*/
|
|
|
|
public function getProjectConfig($project_id = 0){
|
|
|
|
$str = '';
|
|
|
|
$imageSettingModel = new ImageSetting();
|
|
|
|
$settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
|
|
|
|
if($settingInfo !== false){
|
|
|
|
if($settingInfo['status'] == 1 && !empty($settingInfo['image_data'])){
|
|
|
|
$image_data = json_decode($settingInfo['image_data'],true);
|
|
|
|
foreach ($image_data as $k => $v){
|
|
|
|
$arr = implode('/',$v);
|
|
|
|
if ($arr[0] == 'image') {
|
|
|
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
|
|
|
if (str_starts_with($v, "image/")) {
|
|
|
|
$v = 'image/'.urlSafeBase64Encode(substr($v, strlen("image/")));
|
|
|
|
}
|
|
|
|
$image_data[$k] = $v;
|
|
|
|
}
|
|
|
|
$str = 'watermark/1/'.implode('/',$image_data);
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
|
|
|
|
$str_data = json_decode($settingInfo['str_data'],true);
|
|
|
|
foreach ($str_data as $k => $v){
|
|
|
|
$arr = implode('/',$v);
|
|
|
|
$arr = explode('/',$v);
|
|
|
|
if ($arr[0] == 'text') {
|
|
|
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
|
|
|
$v = implode('/',$arr);
|
|
|
|
}
|
|
|
|
if ($arr[0] == 'font') {
|
|
|
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
|
|
|
$v = implode('/',$arr);
|
|
|
|
}
|
|
|
|
if ($arr[0] == 'fill') {
|
|
|
|
$arr[1] = urlSafeBase64Encode($arr[1]);
|
|
|
|
$v = implode('/',$arr);
|
|
|
|
}
|
|
|
|
$str_data[$k] = $arr;
|
|
|
|
$str_data[$k] = $v;
|
|
|
|
}
|
|
|
|
$str = 'watermark/2/'.implode('/',$str_data);
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -726,10 +737,10 @@ class ImageController extends Controller |
|
|
|
if($info === false){
|
|
|
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
if($info['status'] == 1 && !empty($info['image_data'])){
|
|
|
|
if($info['status'] == 1 && empty($info['image_data'])){
|
|
|
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
if($info['status'] == 2 && !empty($info['str_data'])){
|
|
|
|
if($info['status'] == 2 && empty($info['str_data'])){
|
|
|
|
$this->response('请先设置水印',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
$imageSetting->edit(['status'=>$this->param['status']],['project_id'=>$this->cache['project_id']]);
|
|
...
|
...
|
@@ -753,7 +764,9 @@ class ImageController extends Controller |
|
|
|
if(!empty($info['str_data'])){
|
|
|
|
$info['str_data'] = json_decode($info['str_data'],true);
|
|
|
|
}
|
|
|
|
$info['domain'] = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->response('success',Code::SUCCESS,$info);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|