|
@@ -28,6 +28,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.google.common.base.Strings;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.tzld.commons.aliyun.oss.AliyunOssManager;
|
|
|
+import com.tzld.crawler.etl.common.CustomValidator;
|
|
|
import com.tzld.crawler.etl.common.base.CommonResponse;
|
|
|
import com.tzld.crawler.etl.common.base.Constant;
|
|
|
import com.tzld.crawler.etl.common.enums.ExceptionEnum;
|
|
@@ -109,6 +110,9 @@ public class EtlServiceImpl implements EtlService {
|
|
|
@Value("${ffprobe.path:ffmpeg}")
|
|
|
private String ffmpegPath;
|
|
|
|
|
|
+ @ApolloJsonValue("${fail.retry.times:{}}")
|
|
|
+ private Map<String, Integer> failRetryTimes;
|
|
|
+
|
|
|
private Executor pool;
|
|
|
|
|
|
public EtlServiceImpl(StrategyHandlerService strategyHandlerService, AliyunOssManager aliyunOssManager,
|
|
@@ -125,29 +129,19 @@ public class EtlServiceImpl implements EtlService {
|
|
|
|
|
|
@Override
|
|
|
public void deal(CrawlerVideoVO param) {
|
|
|
- String title = param.getVideoTitle();
|
|
|
- String platform = param.getPlatform();
|
|
|
- String strategy = param.getStrategy();
|
|
|
+ CrawlerVideo crawlerVideo = new CrawlerVideo();
|
|
|
+ BeanUtils.copyProperties(param, crawlerVideo);
|
|
|
long id = 0L;
|
|
|
try {
|
|
|
-
|
|
|
-
|
|
|
- CrawlerVideo crawlerVideo = new CrawlerVideo();
|
|
|
- BeanUtils.copyProperties(param, crawlerVideo);
|
|
|
- String insertSql =
|
|
|
- "insert into crawler_video(user_id, out_user_id, platform, strategy, out_video_id, video_title,"
|
|
|
- + " cover_url, video_url, duration, publish_time, play_cnt, crawler_rule, width, height) values("
|
|
|
- + crawlerVideo.getUserId() + "," + crawlerVideo.getOutUserId() + ","
|
|
|
- + crawlerVideo.getPlatform() + "," + crawlerVideo.getStrategy() + ","
|
|
|
- + crawlerVideo.getOutVideoId() + "," + crawlerVideo.getVideoTitle() + ","
|
|
|
- + crawlerVideo.getCoverUrl() + "," + crawlerVideo.getVideoUrl() + ","
|
|
|
- + crawlerVideo.getDuration() + "," + crawlerVideo.getPublishTime() + ","
|
|
|
- + crawlerVideo.getPlayCnt() + "," + crawlerVideo.getCrawlerRule() + ","
|
|
|
- + crawlerVideo.getWidth() + "," + crawlerVideo.getHeight() + ")";
|
|
|
- slsService.log("message", "insert_sql: " + insertSql, "crawler", platform, "mode", strategy);
|
|
|
- crawlerVideoExtMapper.insertSelectiveReturnId(crawlerVideo);
|
|
|
- id = crawlerVideo.getId();
|
|
|
- slsService.log("message", "视频信息写入数据库成功", "crawler", platform, "mode", strategy);
|
|
|
+
|
|
|
+ String errorMessage = CustomValidator.validate(param);
|
|
|
+ if (!Strings.isNullOrEmpty(errorMessage)) {
|
|
|
+ log.error("param validate failed. {}", errorMessage);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ id = save2db(crawlerVideo);
|
|
|
|
|
|
|
|
|
|
|
@@ -164,107 +158,156 @@ public class EtlServiceImpl implements EtlService {
|
|
|
processVideo(data);
|
|
|
|
|
|
|
|
|
- CrawlerVideoSendParam request = new CrawlerVideoSendParam();
|
|
|
- request.setLoginUid(data.getUserId());
|
|
|
- request.setAppType(888888);
|
|
|
- request.setTitle(title);
|
|
|
- request.setVideoPath(data.getVideoOssPath());
|
|
|
- request.setCoverImgPath(data.getCoverOssPath());
|
|
|
- request.setTotalTime(data.getDuration());
|
|
|
- request.setVersionCode(1);
|
|
|
- request.setViewStatus(1);
|
|
|
- request.setCrawlerSrcId(data.getOutVideoId());
|
|
|
- request.setCrawlerSrcCode(platform.toUpperCase());
|
|
|
- LocalDateTime localDateTime =
|
|
|
- LocalDateTime.parse(data.getPublishTime(), DateTimeFormatter.ofPattern(Constant.STANDARD_FORMAT));
|
|
|
- request.setCrawlerSrcPublishTimestamp(localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
|
- request.setCrawlerTaskTimestamp(System.currentTimeMillis());
|
|
|
- CommonResponse<WxVideoVO> response = longVideoFeign.crawlerVideoSend(request);
|
|
|
- log.info("crawler data send request: {}, response: {}", request, response);
|
|
|
- if (!response.isSuccess()) {
|
|
|
- throw new CommonException(ExceptionEnum.INVOKE_VIDEOAPI_ERROR,
|
|
|
- "invoke crawler data send failed!" + response);
|
|
|
- }
|
|
|
+ long videoId = videoSend(data);
|
|
|
|
|
|
|
|
|
- crawlerVideo.setVideoId(response.getData().getId());
|
|
|
- crawlerVideo.setTitleScore(data.getTitleScore());
|
|
|
- crawlerVideoMapper.updateByPrimaryKeySelective(crawlerVideo);
|
|
|
+ int retry = 0;
|
|
|
+ int saveVideo2dbRetry = failRetryTimes.getOrDefault("video2db", 3);
|
|
|
|
|
|
-
|
|
|
- pool.execute(() -> {
|
|
|
+ while (retry < saveVideo2dbRetry) {
|
|
|
+ retry++;
|
|
|
try {
|
|
|
- String sheetToken = feishuSheetTokenMap.get(platform);
|
|
|
- if (Strings.isNullOrEmpty(sheetToken)) {
|
|
|
- log.error("feishu.sheet.token.map config of {} is null", platform);
|
|
|
- return;
|
|
|
- }
|
|
|
- String strategyType = Strings.nullToEmpty(param.getStrategyType());
|
|
|
- String sheetId = feishuSheetIdMap.get(platform + strategyType);
|
|
|
- if (Strings.isNullOrEmpty(sheetToken)) {
|
|
|
- log.error("feishu.sheet.id.map config of {} is null", platform);
|
|
|
- return;
|
|
|
+ crawlerVideo.setVideoId(videoId);
|
|
|
+ crawlerVideo.setTitleScore(data.getTitleScore());
|
|
|
+ if (crawlerVideoMapper.updateByPrimaryKeySelective(crawlerVideo) > 0) {
|
|
|
+ break;
|
|
|
}
|
|
|
- String range = feishuRangeMap.get(platform + strategyType);
|
|
|
-
|
|
|
- log.info("{} {} sheetToken {} sheetId {} range {}", platform, strategy, sheetToken, sheetId, range);
|
|
|
- String fsResp = FeishuUtils.insertRows(feishuAppid, feishuAppsecret, sheetToken, sheetId, 1, 2);
|
|
|
- log.debug("insert columns to feishu sheet response is {}", fsResp);
|
|
|
-
|
|
|
- List<List<Object>> values = new ArrayList<>();
|
|
|
- List<Object> value = new ArrayList<>();
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Constant.STANDARD_FORMAT);
|
|
|
- if ("search".equals(strategy)) {
|
|
|
- CrawlerUserV3Example example = new CrawlerUserV3Example();
|
|
|
- example.createCriteria().andUidEqualTo(crawlerVideo.getUserId());
|
|
|
- List<CrawlerUserV3> crawlerUserV3s = crawlerUserV3Mapper.selectByExample(example);
|
|
|
- value.add(crawlerUserV3s.size() > 0 ? crawlerUserV3s.get(0).getLink() : "");
|
|
|
- }
|
|
|
-
|
|
|
- value.add(data.getTitleScore());
|
|
|
- value.add(crawlerVideo.getVideoId());
|
|
|
- value.add(formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()),
|
|
|
- ZoneId.systemDefault())));
|
|
|
- value.add(strategy);
|
|
|
- value.add(data.getOutVideoId());
|
|
|
- value.add(data.getVideoTitle());
|
|
|
- value.add(String.format(adminCmsUrl, crawlerVideo.getVideoId()));
|
|
|
- value.add(data.getPlayCnt());
|
|
|
- value.add(data.getCommentCnt());
|
|
|
- value.add(data.getLikeCnt());
|
|
|
- value.add(data.getShareCnt());
|
|
|
- value.add(data.getDuration());
|
|
|
- value.add(data.getWidth() + "*" + data.getHeight());
|
|
|
- value.add(data.getPublishTime());
|
|
|
- value.add(data.getUserName());
|
|
|
- value.add(data.getOutUserId());
|
|
|
- value.add(data.getAvatarUrl());
|
|
|
- value.add(data.getCoverUrl());
|
|
|
- value.add(data.getVideoUrl());
|
|
|
- values.add(value);
|
|
|
-
|
|
|
- fsResp = FeishuUtils.updateValues(feishuAppid, feishuAppsecret, sheetToken, range, values);
|
|
|
- log.debug("update feishu sheet value response is {}", fsResp);
|
|
|
-
|
|
|
- slsService.log("message", "视频已保存至云文档", "crawler", platform, "mode", strategy);
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
- log.error("save data to feishu sheet error. platform {}, strategy {}", platform, strategy, e);
|
|
|
+ log.error("update video info to db failed retry {} times. {}", retry, crawlerVideo, e);
|
|
|
+ if (retry >= saveVideo2dbRetry) {
|
|
|
+ throw new CommonException(ExceptionEnum.SYSTEM_ERROR, "update video info to db failed." + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
- slsService.log("message", "out video id " + param.getOutVideoId() + " has exist", "crawler", platform,
|
|
|
- "mode", strategy);
|
|
|
- log.info("out video id {} of platform {} strategy {} has exist!", param.getOutVideoId(),
|
|
|
- param.getPlatform(), param.getStrategy());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ async2Feishu(data, videoId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("etl server deal {} failed.", param, e);
|
|
|
|
|
|
- crawlerVideoMapper.deleteByPrimaryKey(id);
|
|
|
+ if (id > 0) {
|
|
|
+ crawlerVideoMapper.deleteByPrimaryKey(id);
|
|
|
+ }
|
|
|
throw new CommonException(ExceptionEnum.SYSTEM_ERROR, "etl server deal error: " + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private long save2db(CrawlerVideo crawlerVideo) {
|
|
|
+ long id = 0;
|
|
|
+ int retry = 0;
|
|
|
+ int saveVideo2dbRetry = failRetryTimes.getOrDefault("video2db", 3);
|
|
|
+ while (retry < saveVideo2dbRetry) {
|
|
|
+ retry++;
|
|
|
+ try {
|
|
|
+ crawlerVideoExtMapper.insertSelectiveReturnId(crawlerVideo);
|
|
|
+ slsService.log("message", "视频信息写入数据库成功", "crawler", crawlerVideo.getPlatform(), "mode", crawlerVideo.getStrategy());
|
|
|
+ id = crawlerVideo.getId();
|
|
|
+ break;
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+
|
|
|
+ log.info("out video id {} of platform {} strategy {} has exist!", crawlerVideo.getOutVideoId(),
|
|
|
+ crawlerVideo.getPlatform(), crawlerVideo.getStrategy());
|
|
|
+ throw new CommonException(ExceptionEnum.DATA_ERROR);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("save video info to db failed retry {} times. {}", retry, crawlerVideo, e);
|
|
|
+ if (retry >= saveVideo2dbRetry) {
|
|
|
+ throw new CommonException(ExceptionEnum.SYSTEM_ERROR, "save video info to db failed." + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return id;
|
|
|
+ }
|
|
|
+
|
|
|
+ private long videoSend(StrategyDataDto data) {
|
|
|
+ String platform = data.getPlatform();
|
|
|
+ CrawlerVideoSendParam request = new CrawlerVideoSendParam();
|
|
|
+ request.setLoginUid(data.getUserId());
|
|
|
+ request.setAppType(888888);
|
|
|
+ request.setTitle(data.getVideoTitle());
|
|
|
+ request.setVideoPath(data.getVideoOssPath());
|
|
|
+ request.setCoverImgPath(data.getCoverOssPath());
|
|
|
+ request.setTotalTime(data.getDuration());
|
|
|
+ request.setVersionCode(1);
|
|
|
+ request.setViewStatus(1);
|
|
|
+ request.setCrawlerSrcId(data.getOutVideoId());
|
|
|
+ request.setCrawlerSrcCode(platform.toUpperCase());
|
|
|
+ LocalDateTime localDateTime =
|
|
|
+ LocalDateTime.parse(data.getPublishTime(), DateTimeFormatter.ofPattern(Constant.STANDARD_FORMAT));
|
|
|
+ request.setCrawlerSrcPublishTimestamp(localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
|
+ request.setCrawlerTaskTimestamp(System.currentTimeMillis());
|
|
|
+ CommonResponse<WxVideoVO> response = longVideoFeign.crawlerVideoSend(request);
|
|
|
+ log.info("crawler send video request: {}, response: {}", request, response);
|
|
|
+ if (!response.isSuccess() || response.getData() == null || response.getData().getId() == null) {
|
|
|
+ throw new CommonException(ExceptionEnum.INVOKE_VIDEOAPI_ERROR,
|
|
|
+ "invoke crawler send video failed!" + response);
|
|
|
+ }
|
|
|
+ return response.getData().getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void async2Feishu(StrategyDataDto data, long videoId) {
|
|
|
+ String platform = data.getPlatform();
|
|
|
+ String strategy = data.getStrategy();
|
|
|
+ pool.execute(() -> {
|
|
|
+ try {
|
|
|
+ String sheetToken = feishuSheetTokenMap.get(platform);
|
|
|
+ if (Strings.isNullOrEmpty(sheetToken)) {
|
|
|
+ log.error("feishu.sheet.token.map config of {} is null", platform);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String strategyType = Strings.nullToEmpty(data.getStrategyType());
|
|
|
+ String sheetId = feishuSheetIdMap.get(platform + strategyType);
|
|
|
+ if (Strings.isNullOrEmpty(sheetToken)) {
|
|
|
+ log.error("feishu.sheet.id.map config of {} is null", platform);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String range = feishuRangeMap.get(platform + strategyType);
|
|
|
+
|
|
|
+ log.info("{} {} sheetToken {} sheetId {} range {}", platform, strategy, sheetToken, sheetId, range);
|
|
|
+ String fsResp = FeishuUtils.insertRows(feishuAppid, feishuAppsecret, sheetToken, sheetId, 1, 2);
|
|
|
+ log.debug("insert columns to feishu sheet response is {}", fsResp);
|
|
|
+
|
|
|
+ List<List<Object>> values = new ArrayList<>();
|
|
|
+ List<Object> value = new ArrayList<>();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Constant.STANDARD_FORMAT);
|
|
|
+ if ("search".equals(strategy)) {
|
|
|
+ CrawlerUserV3Example example = new CrawlerUserV3Example();
|
|
|
+ example.createCriteria().andUidEqualTo(data.getUserId());
|
|
|
+ List<CrawlerUserV3> crawlerUserV3s = crawlerUserV3Mapper.selectByExample(example);
|
|
|
+ value.add(crawlerUserV3s.size() > 0 ? crawlerUserV3s.get(0).getLink() : "");
|
|
|
+ }
|
|
|
+
|
|
|
+ value.add(data.getTitleScore());
|
|
|
+ value.add(videoId);
|
|
|
+ value.add(formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()),
|
|
|
+ ZoneId.systemDefault())));
|
|
|
+ value.add(strategy);
|
|
|
+ value.add(data.getOutVideoId());
|
|
|
+ value.add(data.getVideoTitle());
|
|
|
+ value.add(String.format(adminCmsUrl, videoId));
|
|
|
+ value.add(data.getPlayCnt());
|
|
|
+ value.add(data.getCommentCnt());
|
|
|
+ value.add(data.getLikeCnt());
|
|
|
+ value.add(data.getShareCnt());
|
|
|
+ value.add(data.getDuration());
|
|
|
+ value.add(data.getWidth() + "*" + data.getHeight());
|
|
|
+ value.add(data.getPublishTime());
|
|
|
+ value.add(data.getUserName());
|
|
|
+ value.add(data.getOutUserId());
|
|
|
+ value.add(data.getAvatarUrl());
|
|
|
+ value.add(data.getCoverUrl());
|
|
|
+ value.add(data.getVideoUrl());
|
|
|
+ values.add(value);
|
|
|
+
|
|
|
+ fsResp = FeishuUtils.updateValues(feishuAppid, feishuAppsecret, sheetToken, range, values);
|
|
|
+ log.debug("update feishu sheet value response is {}", fsResp);
|
|
|
+
|
|
|
+ slsService.log("message", "视频已保存至云文档", "crawler", platform, "mode", strategy);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("save data to feishu sheet error. platform {}, strategy {}", platform, strategy, e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private void processVideo(StrategyDataDto data) throws IOException {
|
|
|
String title = data.getVideoTitle();
|
|
|
String platform = data.getPlatform();
|
|
@@ -274,12 +317,26 @@ public class EtlServiceImpl implements EtlService {
|
|
|
String videoPath = urlDownload(data.getVideoUrl(), "longvideo/crawler_local/video", title);
|
|
|
|
|
|
if (!Strings.isNullOrEmpty(audioUrl)) {
|
|
|
- String auditPath = urlDownload(data.getAudioUrl(), "longvideo/crawler_local/audit", title);
|
|
|
- VideoUtils.videoCompose(ffmpegPath, downloadPath + File.separator + videoPath,
|
|
|
- downloadPath + File.separator + auditPath, downloadPath + File.separator + videoPath + "_comp.mp4");
|
|
|
+ String audioPath = urlDownload(data.getAudioUrl(), "longvideo/crawler_local/audio", title);
|
|
|
+ int retry = 0;
|
|
|
+ int synthesisRetry = failRetryTimes.getOrDefault("synthesis", 3);
|
|
|
+ while (retry < synthesisRetry) {
|
|
|
+ retry++;
|
|
|
+ try {
|
|
|
+ VideoUtils.videoSynthesis(ffmpegPath, downloadPath + File.separator + videoPath,
|
|
|
+ downloadPath + File.separator + audioPath, downloadPath + File.separator + videoPath + "_comp.mp4");
|
|
|
+ break;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("video audio synthesis error retry {} times. {},{}", retry, videoPath, audioPath);
|
|
|
+ if (retry >= synthesisRetry) {
|
|
|
+ throw new CommonException(ExceptionEnum.DATA_ERROR, "video synthesis error");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
Files.deleteIfExists(Paths.get(new File(downloadPath + File.separator + videoPath).getPath()));
|
|
|
- Files.deleteIfExists(Paths.get(new File(downloadPath + File.separator + auditPath).getPath()));
|
|
|
+ Files.deleteIfExists(Paths.get(new File(downloadPath + File.separator + audioPath).getPath()));
|
|
|
videoPath += "_comp.mp4";
|
|
|
}
|
|
|
|
|
@@ -299,7 +356,7 @@ public class EtlServiceImpl implements EtlService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- log.info("begin delete: {}", tempFilePath);
|
|
|
+ log.info("begin delete {}", tempFilePath);
|
|
|
Files.deleteIfExists(Paths.get(new File(tempFilePath).getPath()));
|
|
|
|
|
|
|
|
@@ -309,7 +366,7 @@ public class EtlServiceImpl implements EtlService {
|
|
|
tempFilePath = downloadPath + File.separator + videoPath;
|
|
|
|
|
|
|
|
|
- log.info("begin delete: {}", tempFilePath);
|
|
|
+ log.info("begin delete {}", tempFilePath);
|
|
|
Files.deleteIfExists(Paths.get(new File(tempFilePath).getPath()));
|
|
|
}
|
|
|
|
|
@@ -329,27 +386,47 @@ public class EtlServiceImpl implements EtlService {
|
|
|
|
|
|
|
|
|
int retry = 0;
|
|
|
- boolean downloadFlag = false;
|
|
|
- while (retry < 1) {
|
|
|
+ int downloadRetry = failRetryTimes.getOrDefault("download", 3);
|
|
|
+ while (retry < downloadRetry) {
|
|
|
retry++;
|
|
|
- downloadFlag = FileUtils.download(fileUrl, localFilePath + File.separator + titleMmd5);
|
|
|
- if (downloadFlag) {
|
|
|
+ try {
|
|
|
+ FileUtils.download(fileUrl, localFilePath + File.separator + titleMmd5);
|
|
|
break;
|
|
|
+ } catch (CommonException e) {
|
|
|
+ if (e.getCode() == ExceptionEnum.URL_FORBIDDEN.getCode()) {
|
|
|
+ log.error("access to the url {} of remote server is prohibited.", fileUrl);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("download file failed retry {} times. from url {} to file {}. ", fileUrl, filePath, retry);
|
|
|
+ if (retry >= downloadRetry) {
|
|
|
+ throw new CommonException(ExceptionEnum.SYSTEM_ERROR, "download file " + fileUrl + " failed!");
|
|
|
+ }
|
|
|
}
|
|
|
- log.warn("download file failed. retry times: {}, from file {} to {}. ", fileUrl, filePath, retry);
|
|
|
- }
|
|
|
- if (!downloadFlag) {
|
|
|
- throw new CommonException(ExceptionEnum.SYSTEM_ERROR, "download file " + fileUrl + " failed!");
|
|
|
}
|
|
|
|
|
|
return videoFilePath + File.separator + titleMmd5;
|
|
|
}
|
|
|
|
|
|
- private void file2oss(String localFile, String ossBucketKey, String crawler, String mode) throws IOException {
|
|
|
+ private void file2oss(String localFile, String ossBucketKey, String crawler, String mode) {
|
|
|
|
|
|
slsService.log("message", "开始上传视频... ", "crawler", crawler, "mode", mode);
|
|
|
- log.info("begin upload: {} to oss key: {}", localFile, ossBucketKey);
|
|
|
- aliyunOssManager.putObject(ossBucket, ossBucketKey, Files.newInputStream(Paths.get(localFile)));
|
|
|
+ log.info("begin upload {} to oss key {}", localFile, ossBucketKey);
|
|
|
+
|
|
|
+ int retry = 0;
|
|
|
+ int file2ossRetry = failRetryTimes.getOrDefault("2oss", 3);
|
|
|
+ while (retry < file2ossRetry) {
|
|
|
+ retry++;
|
|
|
+ try {
|
|
|
+ aliyunOssManager.putObject(ossBucket, ossBucketKey, Files.newInputStream(Paths.get(localFile)));
|
|
|
+ break;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("upload file to oss failed retry {} times. from url {} to {}. ", retry, localFile, ossBucketKey);
|
|
|
+ if (retry >= file2ossRetry) {
|
|
|
+ throw new CommonException(ExceptionEnum.SYSTEM_ERROR, "upload file " + localFile + " to oss failed!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@PostConstruct
|