feat[后台管理]:图片的预览和下载功能
This commit is contained in:
+1
@@ -94,6 +94,7 @@ public interface CommonConstant {
|
||||
*/
|
||||
String MONTH_FORMAT = "yyyy-MM";
|
||||
String DATE_FORMAT = "yyyy-MM-dd";
|
||||
String DATEMINUTE_FORMAT = "yyyy-MM-dd HH:mm";
|
||||
String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
String SIMPLE_MONTH_FORMAT = "yyyyMM";
|
||||
String SIMPLE_DATE_FORMAT = "yyyyMMdd";
|
||||
|
||||
+20
@@ -1,7 +1,9 @@
|
||||
package com.central.oss.template;
|
||||
|
||||
import com.aliyun.oss.HttpMethod;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
|
||||
import com.aliyun.oss.model.OSSObject;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
@@ -134,6 +136,24 @@ public class OssTemplate implements InitializingBean {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缩略图预览地址
|
||||
* @param objectName 对象名
|
||||
* @return
|
||||
*/
|
||||
public String getViewUrl(String objectName,String style) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, 7);
|
||||
if (style == null) {
|
||||
style = "image/resize,m_fixed,w_100,h_90"; // 默认缩略图样式
|
||||
}
|
||||
GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(fileProperties.getOss().getBucketName(), objectName, HttpMethod.GET);
|
||||
req.setProcess(style);
|
||||
req.setExpiration(cal.getTime());
|
||||
URL url = ossClient.generatePresignedUrl(req);
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预览地址
|
||||
* @param objectName 对象名
|
||||
|
||||
Reference in New Issue
Block a user