|
@@ -1,5 +1,6 @@
|
|
|
package com.backendsys.modules.upload.utils.ObjectKey;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.backendsys.modules.sdk.douyincloud.tos.service.DouyinTosService;
|
|
|
import com.backendsys.modules.sdk.tencentcloud.cos.service.TencentCosService;
|
|
|
import com.backendsys.modules.upload.entity.ObjectKey;
|
|
@@ -46,20 +47,24 @@ public class ObjectKeyUtil {
|
|
|
target = 3;
|
|
|
}
|
|
|
// 去掉协议头(http://、https://)后,再取前缀
|
|
|
- int domainStart = url.indexOf(prefix);
|
|
|
- if (domainStart == -1) {
|
|
|
+ if (StrUtil.isNotEmpty(prefix)) {
|
|
|
+ int domainStart = url.indexOf(prefix);
|
|
|
+ if (domainStart == -1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ // 去掉域名前缀,取后面的路径
|
|
|
+ String object_key = url.substring(domainStart + prefix.length());
|
|
|
+ // 去掉可能的前导斜杠
|
|
|
+ if (object_key.startsWith("/")) {
|
|
|
+ object_key = object_key.substring(1);
|
|
|
+ }
|
|
|
+ ObjectKeyEntity result = new ObjectKeyEntity();
|
|
|
+ result.setObject_key(object_key);
|
|
|
+ result.setTarget(target);
|
|
|
+ return result;
|
|
|
+ } else {
|
|
|
return null;
|
|
|
}
|
|
|
- // 去掉域名前缀,取后面的路径
|
|
|
- String object_key = url.substring(domainStart + prefix.length());
|
|
|
- // 去掉可能的前导斜杠
|
|
|
- if (object_key.startsWith("/")) {
|
|
|
- object_key = object_key.substring(1);
|
|
|
- }
|
|
|
- ObjectKeyEntity result = new ObjectKeyEntity();
|
|
|
- result.setObject_key(object_key);
|
|
|
- result.setTarget(target);
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
/**
|