Commit 45b7074e authored by liuyang's avatar liuyang

添加oss的cdn配置

parent f5fe8e50
......@@ -22,5 +22,7 @@ public class AliyunConfig {
private String bucket;
@Value("${aliyun.vod.region}")
private String region;
@Value("${aliyun.oss.cdn:''}")
private String cdn;
}
package com.qkdata.aliyun.service;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
......@@ -187,7 +188,12 @@ public class AliyunService {
}
public String getPublicUrl() {
return "https://"+aliyunConfig.getBucket()+"."+aliyunConfig.getEndpoint();
if (StrUtil.isNotBlank(aliyunConfig.getCdn())){
return aliyunConfig.getCdn();
}else {
return "https://"+aliyunConfig.getBucket()+"."+aliyunConfig.getEndpoint();
}
}
/**
......
......@@ -127,6 +127,7 @@ aliyun:
oss:
endpoint: oss-cn-beijing.aliyuncs.com
bucket: qkdata-online-edu
cdn:
vod:
region: cn-shanghai
alipay:
......
package com.qkdata.test;
import com.qkdata.aliyun.service.AliyunService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class AliyunServiceTest extends BaseTest{
@Autowired
private AliyunService aliyunService;
@Test
public void getPublicUrlTest(){
System.out.println(">>>>>>>>>>>>>>>>>"+aliyunService.getPublicUrl());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment