fix:去掉视频预热

This commit is contained in:
2026-08-18 22:43:03 +08:00
parent 01ad2c3c75
commit 36f21fa340
2 changed files with 34 additions and 2 deletions
@@ -6,6 +6,7 @@ import com.aliyuncs.cdn.model.v20180510.*;
import com.aliyuncs.profile.DefaultProfile;
import com.central.file.config.CdnConfig;
import com.central.file.service.ICdnService;
import com.central.file.utils.CdnUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -14,6 +15,7 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* CDN服务实现类
@@ -94,9 +96,25 @@ public class CdnServiceImpl implements ICdnService {
return null;
}
// 过滤掉视频文件:视频体积大且点播命中率低,预热会造成大量CDN回源流量
List<String> nonVideoUrls = urls.stream()
.filter(url -> {
if (CdnUtils.isVideoFile(url)) {
log.info("跳过视频文件预热: {}", url);
return false;
}
return true;
})
.collect(Collectors.toList());
if (nonVideoUrls.isEmpty()) {
log.info("过滤后无需要预热的文件(均为视频),跳过预热");
return null;
}
try {
PushObjectCacheRequest request = new PushObjectCacheRequest();
request.setObjectPath(String.join("\n", urls));
request.setObjectPath(String.join("\n", nonVideoUrls));
if (area != null && !area.isEmpty()) {
request.setArea(area);
}