|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.reghao.oss.store.rpc;
|
|
|
|
|
|
+import cn.reghao.oss.store.config.OssProperties;
|
|
|
import cn.reghao.oss.store.util.JwtUtil;
|
|
|
import cn.reghao.oss.api.constant.ChannelAction;
|
|
|
import cn.reghao.oss.api.constant.UploadChannel;
|
|
|
@@ -16,16 +17,22 @@ import org.springframework.stereotype.Service;
|
|
|
@DubboService
|
|
|
@Service
|
|
|
public class OssServerServiceImpl implements OssServerService {
|
|
|
+ private final String domain;
|
|
|
+
|
|
|
+ public OssServerServiceImpl(OssProperties ossProperties) {
|
|
|
+ this.domain = ossProperties.getDomain();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ServerInfo getServerInfo(long userId, int channelId) {
|
|
|
String action = ChannelAction.upload.getName();
|
|
|
long expireAt = System.currentTimeMillis() + 3600*1000;
|
|
|
// String signKey = RandomString.getSalt(64);
|
|
|
- String signKey = "oss.reghao.cn";
|
|
|
+ String signKey = domain;
|
|
|
OssPayload ossPayload = new OssPayload(action, channelId, userId);
|
|
|
String token = JwtUtil.createToken(ossPayload, expireAt, signKey);
|
|
|
|
|
|
- String ossUrl = "https://oss.reghao.cn/";
|
|
|
+ String ossUrl = String.format("https://%s/", domain);
|
|
|
long maxSize = UploadChannel.getUploadChannel(channelId).getMaxSize();
|
|
|
return new ServerInfo(ossUrl, channelId, maxSize, token);
|
|
|
}
|