|
@@ -43,11 +43,6 @@ public class ImageFileProcessor {
|
|
|
String dupObjectId = objectResult.getDupObjectId();
|
|
String dupObjectId = objectResult.getDupObjectId();
|
|
|
ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
|
|
ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
|
|
|
|
|
|
|
|
- String originalUrl = imageFile.getOriginalUrl();
|
|
|
|
|
- String originalObjectName = objectNameService.getObjectNameFromUrl(originalUrl);
|
|
|
|
|
- ObjectResult objectResult1 = putObjectService.copyObject(originalObjectName);
|
|
|
|
|
- String originalUrl1 = objectResult1.getUploadFileRet().getUrl();
|
|
|
|
|
-
|
|
|
|
|
String jpegUrl = imageFile.getJpegUrl();
|
|
String jpegUrl = imageFile.getJpegUrl();
|
|
|
String jpegObjectName = objectNameService.getObjectNameFromUrl(jpegUrl);
|
|
String jpegObjectName = objectNameService.getObjectNameFromUrl(jpegUrl);
|
|
|
ObjectResult objectResult2 = putObjectService.copyObject(jpegObjectName);
|
|
ObjectResult objectResult2 = putObjectService.copyObject(jpegObjectName);
|
|
@@ -62,7 +57,7 @@ public class ImageFileProcessor {
|
|
|
int height = imageFile.getHeight();
|
|
int height = imageFile.getHeight();
|
|
|
boolean horizontal = imageFile.getHorizontal();
|
|
boolean horizontal = imageFile.getHorizontal();
|
|
|
|
|
|
|
|
- ImageFile imageFile1 = new ImageFile(objectId, width, height, horizontal, originalUrl1, jpegUrl1, webpUrl1);
|
|
|
|
|
|
|
+ ImageFile imageFile1 = new ImageFile(objectId, width, height, horizontal, jpegUrl1, webpUrl1);
|
|
|
mediaRepository.saveImageFile(imageFile1);
|
|
mediaRepository.saveImageFile(imageFile1);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -89,9 +84,8 @@ public class ImageFileProcessor {
|
|
|
|
|
|
|
|
ImageOps.Size size = ImageOps.info(new File(absolutePath));
|
|
ImageOps.Size size = ImageOps.info(new File(absolutePath));
|
|
|
boolean horizontal = size.getWidth() > size.getHeight();
|
|
boolean horizontal = size.getWidth() > size.getHeight();
|
|
|
- String originalUrl = objectNameService.getObjectUrl(objectName);
|
|
|
|
|
ImageFile imageFile =
|
|
ImageFile imageFile =
|
|
|
- new ImageFile(objectId, size.getWidth(), size.getHeight(), horizontal, originalUrl, jpegUrl, webpUrl);
|
|
|
|
|
|
|
+ new ImageFile(objectId, size.getWidth(), size.getHeight(), horizontal, jpegUrl, webpUrl);
|
|
|
mediaRepository.saveImageFile(imageFile);
|
|
mediaRepository.saveImageFile(imageFile);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -100,17 +94,17 @@ public class ImageFileProcessor {
|
|
|
|
|
|
|
|
private String getJpegUrl(String originalPath) throws Exception {
|
|
private String getJpegUrl(String originalPath) throws Exception {
|
|
|
byte[] bytes = ImageOps.convert2jpg(new File(originalPath));
|
|
byte[] bytes = ImageOps.convert2jpg(new File(originalPath));
|
|
|
- return saveImage(bytes);
|
|
|
|
|
|
|
+ return saveImage(bytes, ".jpeg");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String getWebpUrl(String originalPath) throws Exception {
|
|
private String getWebpUrl(String originalPath) throws Exception {
|
|
|
BufferedImage bi = ImageIO.read(new File(originalPath));
|
|
BufferedImage bi = ImageIO.read(new File(originalPath));
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
ImageIO.write(bi, "webp", baos);
|
|
ImageIO.write(bi, "webp", baos);
|
|
|
- return saveImage(baos.toByteArray());
|
|
|
|
|
|
|
+ return saveImage(baos.toByteArray(), ".webp");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private String saveImage(byte[] bytes) throws Exception {
|
|
|
|
|
|
|
+ private String saveImage(byte[] bytes, String suffix) throws Exception {
|
|
|
ObjectProp objectProp = objectNameService.getObjectProp(UploadChannel.cover.getCode());
|
|
ObjectProp objectProp = objectNameService.getObjectProp(UploadChannel.cover.getCode());
|
|
|
String contentId = UUID.randomUUID().toString().replace("-", "");
|
|
String contentId = UUID.randomUUID().toString().replace("-", "");
|
|
|
File savedFile = fileStoreService.saveFile(bytes, contentId);
|
|
File savedFile = fileStoreService.saveFile(bytes, contentId);
|