Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
sentinel
Commits
055bb283
Commit
055bb283
authored
Feb 26, 2019
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
c197b9da
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
1 deletion
+83
-1
pom.xml
pom.xml
+5
-1
AliyunApiController.java
...main/java/com/egolm/film/api/web/AliyunApiController.java
+70
-0
application-dev.properties
src/main/resources/application-dev.properties
+3
-0
application-pro.properties
src/main/resources/application-pro.properties
+3
-0
application-proupload.properties
src/main/resources/application-proupload.properties
+2
-0
No files found.
pom.xml
View file @
055bb283
...
@@ -95,7 +95,11 @@
...
@@ -95,7 +95,11 @@
<artifactId>
aliyun-java-sdk-vod
</artifactId>
<artifactId>
aliyun-java-sdk-vod
</artifactId>
<version>
2.11.6
</version>
<version>
2.11.6
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.3.0
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
src/main/java/com/egolm/film/api/web/AliyunApiController.java
View file @
055bb283
package
com
.
egolm
.
film
.
api
.
web
;
package
com
.
egolm
.
film
.
api
.
web
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -15,6 +17,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -15,6 +17,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyun.oss.OSSClient
;
import
com.aliyun.oss.common.utils.BinaryUtil
;
import
com.aliyun.oss.model.MatchMode
;
import
com.aliyun.oss.model.PolicyConditions
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse
;
import
com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
...
@@ -43,6 +49,13 @@ public class AliyunApiController {
...
@@ -43,6 +49,13 @@ public class AliyunApiController {
@Value
(
"${aliyun.sts.accessKeySecret}"
)
@Value
(
"${aliyun.sts.accessKeySecret}"
)
private
String
accessKeySecret
;
private
String
accessKeySecret
;
@Value
(
"${aliyun.oss.endpoint}"
)
private
String
endpoint
;
@Value
(
"${aliyun.oss.bucket}"
)
private
String
bucket
;
@Value
(
"${aliyun.video.templateGroupId}"
)
@Value
(
"${aliyun.video.templateGroupId}"
)
private
String
templateGroupId
;
private
String
templateGroupId
;
...
@@ -146,6 +159,60 @@ public class AliyunApiController {
...
@@ -146,6 +159,60 @@ public class AliyunApiController {
}
}
}
}
@ResponseBody
@ApiOperation
(
"获取OSS上传凭证"
)
@RequestMapping
(
value
=
"/getOssPolicy"
,
method
=
RequestMethod
.
GET
)
public
Object
getOssPolicy
()
{
String
host
=
"//"
+
bucket
+
"."
+
endpoint
;
// host的格式为 bucketname.endpoint
// callbackUrl为 上传回调服务器的URL,请将下面的IP和Port配置为您自己的真实信息。
//String callbackUrl = "http://88.88.88.88.:8888";
String
dir
=
"film/"
;
// 用户上传文件时指定的前缀。
OSSClient
client
=
new
OSSClient
(
endpoint
,
accessKeyId
,
accessKeySecret
);
try
{
long
expireTime
=
30
;
long
expireEndTime
=
System
.
currentTimeMillis
()
+
expireTime
*
1000
;
Date
expiration
=
new
Date
(
expireEndTime
);
PolicyConditions
policyConds
=
new
PolicyConditions
();
policyConds
.
addConditionItem
(
PolicyConditions
.
COND_CONTENT_LENGTH_RANGE
,
0
,
1048576000
);
policyConds
.
addConditionItem
(
MatchMode
.
StartWith
,
PolicyConditions
.
COND_KEY
,
dir
);
String
postPolicy
=
client
.
generatePostPolicy
(
expiration
,
policyConds
);
byte
[]
binaryData
=
postPolicy
.
getBytes
(
"utf-8"
);
String
encodedPolicy
=
BinaryUtil
.
toBase64String
(
binaryData
);
String
postSignature
=
client
.
calculatePostSignature
(
postPolicy
);
Map
<
String
,
String
>
respMap
=
new
LinkedHashMap
<
String
,
String
>();
respMap
.
put
(
"accessid"
,
accessKeyId
);
respMap
.
put
(
"policy"
,
encodedPolicy
);
respMap
.
put
(
"signature"
,
postSignature
);
respMap
.
put
(
"dir"
,
dir
);
respMap
.
put
(
"host"
,
host
);
respMap
.
put
(
"expire"
,
String
.
valueOf
(
expireEndTime
/
1000
));
// respMap.put("expire", formatISO8601Date(expiration));
/*
JSONObject jasonCallback = new JSONObject();
jasonCallback.put("callbackUrl", callbackUrl);
jasonCallback.put("callbackBody",
"filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}");
jasonCallback.put("callbackBodyType", "application/x-www-form-urlencoded");
String base64CallbackBody = BinaryUtil.toBase64String(jasonCallback.toString().getBytes());
respMap.put("callback", base64CallbackBody);
*/
return
Rjx
.
jsonOk
().
set
(
"detail"
,
respMap
);
}
catch
(
Exception
e
)
{
// Assert.fail(e.getMessage());
System
.
out
.
println
(
e
.
getMessage
());
}
return
Rjx
.
jsonErr
().
setMessage
(
"上传凭证获取失败"
).
toJson
();
}
/**
/**
* https://help.aliyun.com/document_detail/52839.html?spm=a2c4g.11186623.2.16.56da9028Qxc5wl#TranscodeTemplate
* https://help.aliyun.com/document_detail/52839.html?spm=a2c4g.11186623.2.16.56da9028Qxc5wl#TranscodeTemplate
* @Title: transcode
* @Title: transcode
...
@@ -338,4 +405,7 @@ public class AliyunApiController {
...
@@ -338,4 +405,7 @@ public class AliyunApiController {
return
"处理完成"
;
return
"处理完成"
;
}
}
}
}
src/main/resources/application-dev.properties
View file @
055bb283
...
@@ -39,4 +39,7 @@ aliyun.sts.accessKeySecret=9XTHW7P9TTRvCsBHBSclOue2tdWOoa
...
@@ -39,4 +39,7 @@ aliyun.sts.accessKeySecret=9XTHW7P9TTRvCsBHBSclOue2tdWOoa
#\u89C6\u9891\u8F6C\u7801ID
#\u89C6\u9891\u8F6C\u7801ID
aliyun.video.templateGroupId
=
d9f4a79cba14ce4cbc98d6516d35bf37
aliyun.video.templateGroupId
=
d9f4a79cba14ce4cbc98d6516d35bf37
aliyun.video.cateID
=
1000018495
aliyun.video.cateID
=
1000018495
aliyun.oss.endpoint
=
oss-cn-shanghai.aliyuncs.com
aliyun.oss.bucket
=
siff-film-pic
opt.project.type
=
1
opt.project.type
=
1
\ No newline at end of file
src/main/resources/application-pro.properties
View file @
055bb283
...
@@ -38,4 +38,7 @@ aliyun.sts.accessKeySecret=9XTHW7P9TTRvCsBHBSclOue2tdWOoa
...
@@ -38,4 +38,7 @@ aliyun.sts.accessKeySecret=9XTHW7P9TTRvCsBHBSclOue2tdWOoa
#\u89C6\u9891\u8F6C\u7801ID
#\u89C6\u9891\u8F6C\u7801ID
aliyun.video.templateGroupId
=
d9f4a79cba14ce4cbc98d6516d35bf37
aliyun.video.templateGroupId
=
d9f4a79cba14ce4cbc98d6516d35bf37
aliyun.video.cateID
=
1000018494
aliyun.video.cateID
=
1000018494
aliyun.oss.endpoint
=
oss-cn-shanghai.aliyuncs.com
aliyun.oss.bucket
=
siff-film-pic
opt.project.type
=
1
opt.project.type
=
1
\ No newline at end of file
src/main/resources/application-proupload.properties
View file @
055bb283
...
@@ -38,4 +38,6 @@ aliyun.sts.accessKeySecret=9XTHW7P9TTRvCsBHBSclOue2tdWOoa
...
@@ -38,4 +38,6 @@ aliyun.sts.accessKeySecret=9XTHW7P9TTRvCsBHBSclOue2tdWOoa
#\u89C6\u9891\u8F6C\u7801ID
#\u89C6\u9891\u8F6C\u7801ID
aliyun.video.templateGroupId
=
d9f4a79cba14ce4cbc98d6516d35bf37
aliyun.video.templateGroupId
=
d9f4a79cba14ce4cbc98d6516d35bf37
aliyun.video.cateID
=
1000018494
aliyun.video.cateID
=
1000018494
aliyun.oss.endpoint
=
oss-cn-shanghai.aliyuncs.com
aliyun.oss.bucket
=
siff-film-pic
opt.project.type
=
1
opt.project.type
=
1
\ No newline at end of file
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