Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-aliyun
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
cloud-aliyun
Commits
2ab56c41
Commit
2ab56c41
authored
Jan 09, 2025
by
阳浪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
web端授权签名获得登录校验
parent
28a3439d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/PolicyController.java
+17
-0
No files found.
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/PolicyController.java
View file @
2ab56c41
...
@@ -9,10 +9,14 @@ import com.aliyun.oss.model.MatchMode;
...
@@ -9,10 +9,14 @@ import com.aliyun.oss.model.MatchMode;
import
com.aliyun.oss.model.PolicyConditions
;
import
com.aliyun.oss.model.PolicyConditions
;
import
com.yizhi.aliyun.application.util.AESCoder
;
import
com.yizhi.aliyun.application.util.AESCoder
;
import
com.yizhi.aliyun.application.util.PropertiesUtil
;
import
com.yizhi.aliyun.application.util.PropertiesUtil
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.core.application.context.RequestContext
;
import
com.yizhi.util.application.domain.Response
;
import
com.yizhi.util.application.domain.Response
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -29,6 +33,8 @@ import java.util.Map;
...
@@ -29,6 +33,8 @@ import java.util.Map;
@RequestMapping
(
value
=
"/upload"
)
@RequestMapping
(
value
=
"/upload"
)
public
class
PolicyController
{
public
class
PolicyController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
PolicyController
.
class
);
@Value
(
"${ACTIVE}"
)
@Value
(
"${ACTIVE}"
)
public
String
active
;
public
String
active
;
...
@@ -38,6 +44,12 @@ public class PolicyController {
...
@@ -38,6 +44,12 @@ public class PolicyController {
@ApiOperation
(
value
=
"web端上传签名获得"
,
notes
=
"web端上传签名获得"
,
response
=
Response
.
class
)
@ApiOperation
(
value
=
"web端上传签名获得"
,
notes
=
"web端上传签名获得"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/policy"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/policy"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
token
(
@RequestParam
(
name
=
"needTranscode"
,
required
=
false
)
Boolean
needTranscode
,
@RequestParam
(
name
=
"type"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
type
)
{
public
Response
<
String
>
token
(
@RequestParam
(
name
=
"needTranscode"
,
required
=
false
)
Boolean
needTranscode
,
@RequestParam
(
name
=
"type"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
type
)
{
RequestContext
context
=
ContextHolder
.
get
();
if
(
context
==
null
||
context
.
getAccountId
()==
null
||
context
.
getAccountId
()==
0L
){
return
Response
.
fail
(
"未登录!禁止访问"
);
}
LOGGER
.
info
(
"登录人:{},{}"
,
context
.
getAccountId
(),
context
.
getAccountName
());
String
endpoint
=
propertiesUtil
.
getPublicParam
().
get
(
"endpoint"
);
String
endpoint
=
propertiesUtil
.
getPublicParam
().
get
(
"endpoint"
);
String
accessId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
String
accessId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
String
accessKey
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
String
accessKey
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
...
@@ -113,6 +125,11 @@ public class PolicyController {
...
@@ -113,6 +125,11 @@ public class PolicyController {
public
Response
<
String
>
download
(
public
Response
<
String
>
download
(
@ApiParam
(
name
=
"key"
,
value
=
"文件在oss存储路径"
,
required
=
true
)
@RequestParam
(
value
=
"key"
,
required
=
true
)
String
key
@ApiParam
(
name
=
"key"
,
value
=
"文件在oss存储路径"
,
required
=
true
)
@RequestParam
(
value
=
"key"
,
required
=
true
)
String
key
)
{
)
{
RequestContext
context
=
ContextHolder
.
get
();
if
(
context
==
null
||
context
.
getAccountId
()==
null
||
context
.
getAccountId
()==
0L
){
return
Response
.
fail
(
"未登录!禁止访问"
);
}
LOGGER
.
info
(
"登录人:{},{}"
,
context
.
getAccountId
(),
context
.
getAccountName
());
String
endpoint
=
propertiesUtil
.
getPublicParam
().
get
(
"endpoint"
);
String
endpoint
=
propertiesUtil
.
getPublicParam
().
get
(
"endpoint"
);
String
accessId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
String
accessId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
String
accessKey
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
String
accessKey
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
...
...
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