mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-11-14 22:49:33 +08:00
⚡ 新增oss内网上传后转换返回外网地址的功能
This commit is contained in:
parent
22e3e046d4
commit
7cc4f67b51
@ -54,7 +54,7 @@ import $!{superControllerClassPackage};
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("#if($!{hasServiceName})/$!{serviceName}#end/$!{entityKey}")
|
||||
@Tag(name = "$!{table.comment}", tags = "$!{table.comment}接口")
|
||||
@Tag(name = "$!{table.comment}", description = "$!{table.comment}接口")
|
||||
#if($!{superControllerClass})
|
||||
public class $!{table.controllerName} extends $!{superControllerClass} {
|
||||
#else
|
||||
|
@ -29,6 +29,7 @@ import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -281,8 +282,8 @@ public class AliossTemplate implements OssTemplate {
|
||||
* @return String
|
||||
*/
|
||||
public String getOssHost(String bucketName) {
|
||||
String prefix = ossProperties.getEndpoint().contains("https://") ? "https://" : "http://";
|
||||
return prefix + getBucketName(bucketName) + StringPool.DOT + ossProperties.getEndpoint().replaceFirst(prefix, StringPool.EMPTY);
|
||||
String prefix = getEndpoint().contains("https://") ? "https://" : "http://";
|
||||
return prefix + getBucketName(bucketName) + StringPool.DOT + getEndpoint().replaceFirst(prefix, StringPool.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,4 +295,17 @@ public class AliossTemplate implements OssTemplate {
|
||||
return getOssHost(ossProperties.getBucketName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务地址
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getEndpoint() {
|
||||
if (StringUtil.isBlank(ossProperties.getTransformEndpoint())) {
|
||||
return ossProperties.getEndpoint();
|
||||
}
|
||||
return ossProperties.getTransformEndpoint();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
@ -162,13 +163,13 @@ public class MinioTemplate implements OssTemplate {
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String fileLink(String fileName) {
|
||||
return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(getBucketName()).concat(StringPool.SLASH).concat(fileName);
|
||||
return getEndpoint().concat(StringPool.SLASH).concat(getBucketName()).concat(StringPool.SLASH).concat(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String fileLink(String bucketName, String fileName) {
|
||||
return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(getBucketName(bucketName)).concat(StringPool.SLASH).concat(fileName);
|
||||
return getEndpoint().concat(StringPool.SLASH).concat(getBucketName(bucketName)).concat(StringPool.SLASH).concat(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -402,7 +403,7 @@ public class MinioTemplate implements OssTemplate {
|
||||
* @return String
|
||||
*/
|
||||
public String getOssHost(String bucketName) {
|
||||
return ossProperties.getEndpoint() + StringPool.SLASH + getBucketName(bucketName);
|
||||
return getEndpoint() + StringPool.SLASH + getBucketName(bucketName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,4 +415,17 @@ public class MinioTemplate implements OssTemplate {
|
||||
return getOssHost(ossProperties.getBucketName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务地址
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getEndpoint() {
|
||||
if (StringUtil.isBlank(ossProperties.getTransformEndpoint())) {
|
||||
return ossProperties.getEndpoint();
|
||||
}
|
||||
return ossProperties.getTransformEndpoint();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.core.tool.utils.CollectionUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
@ -116,13 +117,13 @@ public class QiniuTemplate implements OssTemplate {
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String fileLink(String fileName) {
|
||||
return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(fileName);
|
||||
return getEndpoint().concat(StringPool.SLASH).concat(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String fileLink(String bucketName, String fileName) {
|
||||
return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(fileName);
|
||||
return getEndpoint().concat(StringPool.SLASH).concat(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -260,7 +261,20 @@ public class QiniuTemplate implements OssTemplate {
|
||||
* @return String
|
||||
*/
|
||||
public String getOssHost() {
|
||||
return ossProperties.getEndpoint();
|
||||
return getEndpoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务地址
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getEndpoint() {
|
||||
if (StringUtil.isBlank(ossProperties.getTransformEndpoint())) {
|
||||
return ossProperties.getEndpoint();
|
||||
}
|
||||
return ossProperties.getTransformEndpoint();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -48,6 +48,11 @@ public class OssProperties {
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* 转换外网地址的URL
|
||||
*/
|
||||
private String transformEndpoint;
|
||||
|
||||
/**
|
||||
* Access key就像用户ID,可以唯一标识你的账户
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user