|
|
@@ -6,7 +6,6 @@ import cn.reghao.dfs.store.model.vo.ObjectResult;
|
|
|
import cn.reghao.dfs.store.service.FileStoreService;
|
|
|
import cn.reghao.dfs.store.service.ObjectNameService;
|
|
|
import cn.reghao.dfs.store.service.PutObjectService;
|
|
|
-import cn.reghao.dfs.store.util.StringUtil;
|
|
|
import cn.reghao.jutil.jdk.security.DigestUtil;
|
|
|
import cn.reghao.dfs.store.model.po.ImageFile;
|
|
|
import cn.reghao.jutil.media.ImageOps;
|
|
|
@@ -40,7 +39,7 @@ public class ImageFileProcessor {
|
|
|
this.putObjectService = putObjectService;
|
|
|
}
|
|
|
|
|
|
- public UploadFileRet processCover(ObjectResult objectResult) {
|
|
|
+ public UploadFileRet processImage(ObjectResult objectResult) {
|
|
|
String originalObjectId = objectResult.getObjectId();
|
|
|
boolean duplicate = objectResult.isDuplicate();
|
|
|
if (duplicate) {
|
|
|
@@ -79,55 +78,6 @@ public class ImageFileProcessor {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public UploadFileRet processAvatar(ObjectResult objectResult) {
|
|
|
- String originalObjectId = objectResult.getObjectId();
|
|
|
- boolean duplicate = objectResult.isDuplicate();
|
|
|
- if (duplicate) {
|
|
|
- String dupObjectId = objectResult.getDupObjectId();
|
|
|
- ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
|
|
|
-
|
|
|
- ObjectResult jpegResult = getCopiedObject(imageFile.getJpegUrl());
|
|
|
- String jpegObjectId = jpegResult.getObjectId();
|
|
|
- String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
|
|
|
-
|
|
|
- ObjectResult thumbnailResult = getCopiedObject(imageFile.getThumbnailUrl());
|
|
|
- String thumbnailObjectId = thumbnailResult.getObjectId();
|
|
|
- String thumbnailUrl = objectNameService.getObjectUrl(thumbnailResult.getObjectName());
|
|
|
-
|
|
|
- int width = imageFile.getWidth();
|
|
|
- int height = imageFile.getHeight();
|
|
|
- boolean horizontal = imageFile.getHorizontal();
|
|
|
- ImageFile imageFile1 = new ImageFile(originalObjectId, jpegObjectId, jpegUrl, width, height, horizontal,
|
|
|
- thumbnailObjectId, thumbnailUrl);
|
|
|
- mediaRepository.saveImageFile(imageFile1);
|
|
|
- return new UploadFileRet(originalObjectId, jpegUrl);
|
|
|
- }
|
|
|
-
|
|
|
- String absolutePath = objectResult.getAbsolutePath();
|
|
|
- String format = ImageOps.getFormat(new File(absolutePath));
|
|
|
- try {
|
|
|
- ObjectResult jpegResult = getJpegObject(objectResult, format);
|
|
|
- String jpegObjectId = jpegResult.getObjectId();
|
|
|
- String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
|
|
|
-
|
|
|
- ObjectResult thumbnailResult = getThumbnailObject(objectResult);
|
|
|
- String thumbnailObjectId = thumbnailResult.getObjectId();
|
|
|
- String thumbnailUrl = objectNameService.getObjectUrl(thumbnailResult.getObjectName());
|
|
|
-
|
|
|
- ImageOps.Size size = ImageOps.info(new File(absolutePath));
|
|
|
- int width = size.getWidth();
|
|
|
- int height = size.getHeight();
|
|
|
- boolean horizontal = width > height;
|
|
|
- ImageFile imageFile = new ImageFile(originalObjectId, jpegObjectId, jpegUrl, width, height, horizontal,
|
|
|
- thumbnailObjectId, thumbnailUrl);
|
|
|
- mediaRepository.saveImageFile(imageFile);
|
|
|
- return new UploadFileRet(originalObjectId, jpegUrl);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
public UploadFileRet processPhoto(ObjectResult objectResult) {
|
|
|
String originalObjectId = objectResult.getObjectId();
|
|
|
boolean duplicate = objectResult.isDuplicate();
|
|
|
@@ -177,45 +127,6 @@ public class ImageFileProcessor {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public UploadFileRet processImage(ObjectResult objectResult) {
|
|
|
- String originalObjectId = objectResult.getObjectId();
|
|
|
- boolean duplicate = objectResult.isDuplicate();
|
|
|
- if (duplicate) {
|
|
|
- String dupObjectId = objectResult.getDupObjectId();
|
|
|
- ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
|
|
|
-
|
|
|
- ObjectResult jpegResult = getCopiedObject(imageFile.getJpegUrl());
|
|
|
- String jpegObjectId = jpegResult.getObjectId();
|
|
|
- String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
|
|
|
-
|
|
|
- int width = imageFile.getWidth();
|
|
|
- int height = imageFile.getHeight();
|
|
|
- boolean horizontal = imageFile.getHorizontal();
|
|
|
- ImageFile imageFile1 = new ImageFile(originalObjectId, width, height, horizontal, jpegObjectId, jpegUrl);
|
|
|
- mediaRepository.saveImageFile(imageFile1);
|
|
|
- return new UploadFileRet(originalObjectId, jpegUrl);
|
|
|
- }
|
|
|
-
|
|
|
- String absolutePath = objectResult.getAbsolutePath();
|
|
|
- String format = ImageOps.getFormat(new File(absolutePath));
|
|
|
- try {
|
|
|
- ObjectResult jpegResult = getJpegObject(objectResult, format);
|
|
|
- String jpegObjectId = jpegResult.getObjectId();
|
|
|
- String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
|
|
|
-
|
|
|
- ImageOps.Size size = ImageOps.info(new File(absolutePath));
|
|
|
- int width = size.getWidth();
|
|
|
- int height = size.getHeight();
|
|
|
- boolean horizontal = width > height;
|
|
|
- ImageFile imageFile = new ImageFile(originalObjectId, width, height, horizontal, jpegObjectId, jpegUrl);
|
|
|
- mediaRepository.saveImageFile(imageFile);
|
|
|
- return new UploadFileRet(originalObjectId, jpegUrl);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
private ObjectResult getCopiedObject(String url) {
|
|
|
String objectName = objectNameService.getObjectNameFromUrl(url);
|
|
|
return putObjectService.copyObject(objectName);
|