|
@@ -387,7 +387,7 @@ public class EtlServiceImpl implements EtlService {
|
|
|
|
|
|
// 视频封面下载、上传 OSS
|
|
|
String coverPath = urlDownload(data.getCoverUrl(), "longvideo/crawler_local/image", title, data.getOutVideoId(), platform);
|
|
|
- file2oss(downloadPath + File.separator + coverPath, coverPath, platform, strategy);
|
|
|
+ file2oss(downloadPath + File.separator + coverPath, coverPath, platform, strategy, "image/jpg");
|
|
|
data.setCoverOssPath(coverPath);
|
|
|
tempFilePath = downloadPath + File.separator + coverPath;
|
|
|
|
|
@@ -448,14 +448,18 @@ public class EtlServiceImpl implements EtlService {
|
|
|
return relFileDir + File.separator + fileName;
|
|
|
}
|
|
|
|
|
|
- private void file2oss(String localFile, String ossBucketKey, String crawler, String mode) {
|
|
|
+ private void file2oss(String localFile, String ossBucketKey, String crawler, String mode, String contentType) {
|
|
|
// 文件上传 OSS
|
|
|
slsService.log("message", "开始上传视频... ", "crawler", crawler, "mode", mode);
|
|
|
log.info("begin upload {} to oss key {}", localFile, ossBucketKey);
|
|
|
|
|
|
retrySupplier(() -> {
|
|
|
try {
|
|
|
- aliyunOssManager.putObject(ossBucket, ossBucketKey, Files.newInputStream(Paths.get(localFile)));
|
|
|
+ if (!Strings.isNullOrEmpty(contentType)) {
|
|
|
+ aliyunOssManager.putObject(ossBucket, ossBucketKey, Files.newInputStream(Paths.get(localFile)), contentType);
|
|
|
+ } else {
|
|
|
+ aliyunOssManager.putObject(ossBucket, ossBucketKey, Files.newInputStream(Paths.get(localFile)));
|
|
|
+ }
|
|
|
return false;
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
@@ -463,6 +467,10 @@ public class EtlServiceImpl implements EtlService {
|
|
|
}, "2oss", String.format("upload file [%s] to oss [%s]", localFile, ossBucketKey));
|
|
|
}
|
|
|
|
|
|
+ private void file2oss(String localFile, String ossBucketKey, String crawler, String mode) {
|
|
|
+ file2oss(localFile, ossBucketKey, crawler, mode, null);
|
|
|
+ }
|
|
|
+
|
|
|
private void retrySupplier(BooleanSupplier supplier, String type, String errorMsg) {
|
|
|
retryFunc(c -> supplier.getAsBoolean(), null, type, errorMsg);
|
|
|
}
|