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