作者 lyh

gx脚本demo

@@ -216,22 +216,22 @@ class CosService @@ -216,22 +216,22 @@ class CosService
216 $url = $url.'?watermark/2/'.implode('/',$param); 216 $url = $url.'?watermark/2/'.implode('/',$param);
217 } 217 }
218 // 获取水印后的图片内容 218 // 获取水印后的图片内容
219 -// $imageContent = file_get_contents($url);  
220 -// // 使用 COS SDK 将图片重新上传并覆盖原图  
221 -// $cos = config('filesystems.disks.cos');  
222 -// $cosClient = new \Qcloud\Cos\Client([  
223 -// 'region' => $cos['region'],  
224 -// 'credentials' => [  
225 -// 'secretId' => $cos['credentials']['secretId'],  
226 -// 'secretKey' => $cos['credentials']['secretKey'],  
227 -// ],  
228 -// ]);  
229 -// // 上传并覆盖原图  
230 -// $cosClient->putObject([  
231 -// 'Bucket' => $cos['bucket'],  
232 -// 'Key' => $cdnUrl, // 去掉域名部分,得到存储桶内的路径  
233 -// 'Body' => $imageContent,  
234 -// ]); 219 + $imageContent = file_get_contents($url);
  220 + // 使用 COS SDK 将图片重新上传并覆盖原图
  221 + $cos = config('filesystems.disks.cos');
  222 + $cosClient = new Client([
  223 + 'region' => $cos['region'],
  224 + 'credentials' => [
  225 + 'secretId' => $cos['credentials']['secretId'],
  226 + 'secretKey' => $cos['credentials']['secretKey'],
  227 + ],
  228 + ]);
  229 + // 上传并覆盖原图
  230 + $cosClient->putObject([
  231 + 'Bucket' => $cos['bucket'],
  232 + 'Key' => $cdnUrl, // 去掉域名部分,得到存储桶内的路径
  233 + 'Body' => $imageContent,
  234 + ]);
235 return $url; 235 return $url;
236 } 236 }
237 237