|
@@ -1,6 +1,7 @@
|
|
|
package com.backendsys.modules.sdk.tencentcloud.cos.service.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.io.file.FileNameUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.backendsys.exception.CustException;
|
|
@@ -190,7 +191,7 @@ public class TencentCosServiceImpl implements TencentCosService {
|
|
|
List<String> imageType = Arrays.asList("jpg", "jpeg", "png", "bmp", "webp", "tiff", "gif");
|
|
|
boolean isImage = imageType.contains(CommonUtil.getFilenameSuffix(multipartFile, false).toLowerCase());
|
|
|
if (isImage) {
|
|
|
- // 打水印
|
|
|
+ // 打水印 (如果是图片)
|
|
|
if (is_watermark != null && is_watermark == 1) {
|
|
|
addWatermask(object_key);
|
|
|
}
|
|
@@ -406,7 +407,7 @@ public class TencentCosServiceImpl implements TencentCosService {
|
|
|
|
|
|
// [腾讯云COS] 完成分块上传
|
|
|
@Override
|
|
|
- public CompleteMultipartUploadResult completeMultipartUpload(String upload_id, String object_key, List<PartETag> partETags) {
|
|
|
+ public CompleteMultipartUploadResult completeMultipartUpload(String upload_id, String object_key, List<PartETag> partETags, Integer is_watermark) {
|
|
|
|
|
|
if (StrUtil.isEmpty(upload_id)) throw new CustException("upload_id 不能为空");
|
|
|
if (StrUtil.isEmpty(object_key)) throw new CustException("object_key 不能为空");
|
|
@@ -416,7 +417,20 @@ public class TencentCosServiceImpl implements TencentCosService {
|
|
|
|
|
|
// 分片上传结束后,调用 complete 完成分片上传
|
|
|
CompleteMultipartUploadRequest completeMultipartUploadRequest = new CompleteMultipartUploadRequest(BUCKET_NAME, object_key, upload_id, partETags);
|
|
|
- return cosClient.completeMultipartUpload(completeMultipartUploadRequest);
|
|
|
+ CompleteMultipartUploadResult result = cosClient.completeMultipartUpload(completeMultipartUploadRequest);
|
|
|
+
|
|
|
+ // 判断是图片类型 (这里只能判断后缀名)
|
|
|
+ String suffix = FileNameUtil.getSuffix(object_key);
|
|
|
+ List<String> imageType = Arrays.asList("jpg", "jpeg", "png", "bmp", "webp", "tiff", "gif");
|
|
|
+ boolean isImage = imageType.contains(suffix.toLowerCase());
|
|
|
+ if (isImage) {
|
|
|
+ // 打水印 (如果是图片)
|
|
|
+ if (is_watermark != null && is_watermark == 1) {
|
|
|
+ addWatermask(object_key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
|
|
|
} catch (CosClientException e) {
|
|
|
throw new CustException(e.getMessage());
|