Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
online-edu-backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
online-edu
online-edu-backend
Commits
45b7074e
Commit
45b7074e
authored
Jul 23, 2021
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加oss的cdn配置
parent
f5fe8e50
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
0 deletions
+25
-0
AliyunConfig.java
src/main/java/com/qkdata/aliyun/config/AliyunConfig.java
+2
-0
AliyunService.java
src/main/java/com/qkdata/aliyun/service/AliyunService.java
+6
-0
application.yml
src/main/resources/application.yml
+1
-0
AliyunServiceTest.java
src/test/java/com/qkdata/test/AliyunServiceTest.java
+16
-0
No files found.
src/main/java/com/qkdata/aliyun/config/AliyunConfig.java
View file @
45b7074e
...
@@ -22,5 +22,7 @@ public class AliyunConfig {
...
@@ -22,5 +22,7 @@ public class AliyunConfig {
private
String
bucket
;
private
String
bucket
;
@Value
(
"${aliyun.vod.region}"
)
@Value
(
"${aliyun.vod.region}"
)
private
String
region
;
private
String
region
;
@Value
(
"${aliyun.oss.cdn:''}"
)
private
String
cdn
;
}
}
src/main/java/com/qkdata/aliyun/service/AliyunService.java
View file @
45b7074e
package
com
.
qkdata
.
aliyun
.
service
;
package
com
.
qkdata
.
aliyun
.
service
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyun.oss.OSS
;
import
com.aliyun.oss.OSS
;
import
com.aliyun.oss.OSSClientBuilder
;
import
com.aliyun.oss.OSSClientBuilder
;
...
@@ -187,9 +188,14 @@ public class AliyunService {
...
@@ -187,9 +188,14 @@ public class AliyunService {
}
}
public
String
getPublicUrl
()
{
public
String
getPublicUrl
()
{
if
(
StrUtil
.
isNotBlank
(
aliyunConfig
.
getCdn
())){
return
aliyunConfig
.
getCdn
();
}
else
{
return
"https://"
+
aliyunConfig
.
getBucket
()+
"."
+
aliyunConfig
.
getEndpoint
();
return
"https://"
+
aliyunConfig
.
getBucket
()+
"."
+
aliyunConfig
.
getEndpoint
();
}
}
}
/**
/**
* 获取视频信息
* 获取视频信息
* @param videoId
* @param videoId
...
...
src/main/resources/application.yml
View file @
45b7074e
...
@@ -127,6 +127,7 @@ aliyun:
...
@@ -127,6 +127,7 @@ aliyun:
oss
:
oss
:
endpoint
:
oss-cn-beijing.aliyuncs.com
endpoint
:
oss-cn-beijing.aliyuncs.com
bucket
:
qkdata-online-edu
bucket
:
qkdata-online-edu
cdn
:
vod
:
vod
:
region
:
cn-shanghai
region
:
cn-shanghai
alipay
:
alipay
:
...
...
src/test/java/com/qkdata/test/AliyunServiceTest.java
0 → 100644
View file @
45b7074e
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
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment