|
@@ -5,6 +5,7 @@ import java.io.InputStream;
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeansException;
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.context.ApplicationContext;
|
|
@@ -38,6 +39,11 @@ public class MinioFileHandle implements FileHandle,ApplicationContextAware {
|
|
|
@Value("${sp.minio.secretkey:minioadmin}")
|
|
@Value("${sp.minio.secretkey:minioadmin}")
|
|
|
public String appMinioSecretkey;
|
|
public String appMinioSecretkey;
|
|
|
|
|
|
|
|
|
|
+ @Value("${sp.minio.preview:https://fqgz.flowbb.cn}")
|
|
|
|
|
+ protected String appMinioPreview;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private MinioClient minioClient;
|
|
private MinioClient minioClient;
|
|
|
|
|
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
@@ -131,8 +137,16 @@ public class MinioFileHandle implements FileHandle,ApplicationContextAware {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String getPreviewUrl(String fileKey) throws Exception {
|
|
public String getPreviewUrl(String fileKey) throws Exception {
|
|
|
- // TODO Auto-generated method stub
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(fileKey) && (fileKey.startsWith("http") || fileKey.startsWith("https"))) {
|
|
|
|
|
+ return fileKey;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ String fileUrl = getObjectUrl(fileKey);
|
|
|
|
|
+ int index = fileUrl.indexOf("/", 8);
|
|
|
|
|
+ return appMinioPreview + fileUrl.substring(index);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|