You've already forked FrameTour-BE
更新,sourceId传入无需传url
This commit is contained in:
@ -311,11 +311,11 @@ public class VideoPieceGetter {
|
||||
sourceMapper.addRelation(videoSource);
|
||||
}
|
||||
sourceMapper.add(sourceEntity);
|
||||
videoReUploader.addTask(url, sourceEntity.getId());
|
||||
videoReUploader.addTask(sourceEntity.getId());
|
||||
} else {
|
||||
source.setVideoUrl(url);
|
||||
sourceMapper.update(source);
|
||||
videoReUploader.addTask(url, source.getId());
|
||||
videoReUploader.addTask(source.getId());
|
||||
}
|
||||
} else {
|
||||
// 有原视频
|
||||
|
@ -48,7 +48,7 @@ public class VideoReUploader {
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
|
||||
public void addTask(String url, Long sourceId) {
|
||||
public void addTask(Long sourceId) {
|
||||
SourceEntity entity = sourceMapper.getEntity(sourceId);
|
||||
if (entity == null) {
|
||||
return;
|
||||
@ -65,16 +65,16 @@ public class VideoReUploader {
|
||||
}
|
||||
final String dstFilePath = StorageUtil.joinPath(StorageConstant.VIDEO_PIECE_PATH, entity.getId().toString() + ".mp4");
|
||||
final IStorageAdapter adapter = scenicService.getScenicStorageAdapter(entity.getScenicId());
|
||||
if (StringUtils.equals(url, adapter.getUrl(dstFilePath))) {
|
||||
if (StringUtils.equals(entity.getVideoUrl(), adapter.getUrl(dstFilePath))) {
|
||||
return;
|
||||
}
|
||||
String tmpFilePath = UUID.randomUUID().toString();
|
||||
executor.execute(() -> {
|
||||
// 先下载,后上传
|
||||
File dstFile = new File(tmpFilePath);
|
||||
log.info("下载视频:{};sourceId:{}", url, sourceId);
|
||||
long size = HttpUtil.downloadFile(url, dstFile);
|
||||
log.info("下载视频完成:{};大小:{};sourceId:{}", url, size, sourceId);
|
||||
log.info("下载视频:{};sourceId:{}", entity.getVideoUrl(), sourceId);
|
||||
long size = HttpUtil.downloadFile(entity.getVideoUrl(), dstFile);
|
||||
log.info("下载视频完成:{};大小:{};sourceId:{}", entity.getVideoUrl(), size, sourceId);
|
||||
try {
|
||||
log.info("开始上传:{};sourceId:{}", dstFilePath, sourceId);
|
||||
String newUrl = adapter.uploadFile("video/mp4", dstFile, dstFilePath);
|
||||
|
Reference in New Issue
Block a user