|
|
@ -67,6 +67,10 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
@Value("${oss.aliyun.bucket-name}") |
|
|
@Value("${oss.aliyun.bucket-name}") |
|
|
private String bucketName; |
|
|
private String bucketName; |
|
|
|
|
|
|
|
|
|
|
|
private final static String OSS_THUMBNAIL_DIR = "animal_note/thumbnail/"; |
|
|
|
|
|
private final static String OSS_IMAGE_DIR = "animal_note/image/"; |
|
|
|
|
|
private final static String OSS_VIDEO_DIR = "animal_note/video/"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final AliyunFileService aliyunFileService; |
|
|
private final AliyunFileService aliyunFileService; |
|
|
private final MiniPointRecordService pointRecordService; |
|
|
private final MiniPointRecordService pointRecordService; |
|
|
@ -91,7 +95,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
if (images != null) { |
|
|
if (images != null) { |
|
|
for (MultipartFile image : images) { |
|
|
for (MultipartFile image : images) { |
|
|
try { |
|
|
try { |
|
|
String objectName = "animal_note/image/" |
|
|
String objectName = OSS_IMAGE_DIR |
|
|
+ currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8) |
|
|
+ currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8) |
|
|
+ "." |
|
|
+ "." |
|
|
+ FilenameUtils.getExtension(image.getOriginalFilename()); |
|
|
+ FilenameUtils.getExtension(image.getOriginalFilename()); |
|
|
@ -125,7 +129,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
for (MultipartFile video : videos) { |
|
|
for (MultipartFile video : videos) { |
|
|
try { |
|
|
try { |
|
|
String fileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String fileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String objectName = "animal_note/video/" |
|
|
String objectName = OSS_VIDEO_DIR |
|
|
+ fileName |
|
|
+ fileName |
|
|
+ "." |
|
|
+ "." |
|
|
+ FilenameUtils.getExtension(video.getOriginalFilename()); |
|
|
+ FilenameUtils.getExtension(video.getOriginalFilename()); |
|
|
@ -146,7 +150,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
//缩略图
|
|
|
//缩略图
|
|
|
BufferedImage thumbnail = JavaVCUtils.getVideoThumbnail(videoPath, 1); |
|
|
BufferedImage thumbnail = JavaVCUtils.getVideoThumbnail(videoPath, 1); |
|
|
String thumbnailFileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String thumbnailFileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String thumbnailObjectName = "animal_note/thumbnail/" |
|
|
String thumbnailObjectName = OSS_THUMBNAIL_DIR |
|
|
+ thumbnailFileName |
|
|
+ thumbnailFileName |
|
|
+ ".png"; |
|
|
+ ".png"; |
|
|
String thumbnailUrl = aliyunFileService.uploadFile(thumbnailObjectName, |
|
|
String thumbnailUrl = aliyunFileService.uploadFile(thumbnailObjectName, |
|
|
@ -209,8 +213,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
if (images != null) { |
|
|
if (images != null) { |
|
|
for (MultipartFile image : images) { |
|
|
for (MultipartFile image : images) { |
|
|
try { |
|
|
try { |
|
|
String objectName = "animal_note/" |
|
|
String objectName = OSS_IMAGE_DIR |
|
|
+ note.getId() + "/" |
|
|
|
|
|
+ currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8) |
|
|
+ currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8) |
|
|
+ "." |
|
|
+ "." |
|
|
+ FilenameUtils.getExtension(image.getOriginalFilename()); |
|
|
+ FilenameUtils.getExtension(image.getOriginalFilename()); |
|
|
@ -241,8 +244,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
for (MultipartFile video : videos) { |
|
|
for (MultipartFile video : videos) { |
|
|
try { |
|
|
try { |
|
|
String fileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String fileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String objectName = "animal_note/" |
|
|
String objectName = OSS_VIDEO_DIR |
|
|
+ note.getId() + "/" |
|
|
|
|
|
+ fileName |
|
|
+ fileName |
|
|
+ "." |
|
|
+ "." |
|
|
+ FilenameUtils.getExtension(video.getOriginalFilename()); |
|
|
+ FilenameUtils.getExtension(video.getOriginalFilename()); |
|
|
@ -264,8 +266,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
//缩略图
|
|
|
//缩略图
|
|
|
BufferedImage thumbnail = JavaVCUtils.getVideoThumbnail(videoPath, 1); |
|
|
BufferedImage thumbnail = JavaVCUtils.getVideoThumbnail(videoPath, 1); |
|
|
String thumbnailFileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String thumbnailFileName = currentTimestamp + RandomNumberUtils.createRandomLowerLetterAndNumber(8); |
|
|
String thumbnailObjectName = "animal_note/" |
|
|
String thumbnailObjectName = OSS_THUMBNAIL_DIR |
|
|
+ note.getId() + "/" |
|
|
|
|
|
+ thumbnailFileName |
|
|
+ thumbnailFileName |
|
|
+ ".png"; |
|
|
+ ".png"; |
|
|
String thumbnailUrl = aliyunFileService.uploadFile(thumbnailObjectName, |
|
|
String thumbnailUrl = aliyunFileService.uploadFile(thumbnailObjectName, |
|
|
|