正在显示
1 个修改的文件
包含
16 行增加
和
16 行删除
| @@ -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 |
-
请 注册 或 登录 后发表评论