Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
ufo-platform
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
mali
6 years ago
Commit
b4294bb5f9ebc77d0771e34c9f9f23bbd1285dfe
1 parent
068e8cda
转码
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
9 deletions
.gitignore
common/pom.xml
common/src/main/java/com/yoho/ufo/service/impl/QNUploadServiceImpl.java
pom.xml
web/pom.xml
.gitignore
View file @
b4294bb
...
...
@@ -28,3 +28,4 @@ node_modules
.DS_Store
coupon/src/main/java/META-INF/MANIFEST.MF
resource/src/main/java/META-INF/MANIFEST.MF
searchword/.gitignore
...
...
common/pom.xml
View file @
b4294bb
...
...
@@ -9,7 +9,6 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.yoho.ufo
</groupId>
<artifactId>
ufo-platform-common
</artifactId>
<packaging>
jar
</packaging>
<name>
ufo-platform-common
</name>
...
...
@@ -41,7 +40,7 @@
<dependency>
<groupId>
com.qiniu
</groupId>
<artifactId>
qiniu-java-sdk
</artifactId>
<version>
7.
0.5
</version>
<version>
7.
2.17
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
...
...
@@ -54,6 +53,11 @@
<version>
3.16
</version>
</dependency>
<dependency>
<groupId>
com.squareup.okio
</groupId>
<artifactId>
okio
</artifactId>
<version>
1.13.0
</version>
</dependency>
<dependency>
<artifactId>
yohoufo-fore-inboxclient
</artifactId>
<groupId>
com.yohoufo.fore
</groupId>
</dependency>
...
...
common/src/main/java/com/yoho/ufo/service/impl/QNUploadServiceImpl.java
View file @
b4294bb
...
...
@@ -4,9 +4,11 @@ import com.qiniu.common.QiniuException;
import
com.qiniu.common.Zone
;
import
com.qiniu.http.Response
;
import
com.qiniu.processing.OperationManager
;
import
com.qiniu.processing.OperationStatus
;
import
com.qiniu.storage.BucketManager
;
import
com.qiniu.storage.Configuration
;
import
com.qiniu.storage.UploadManager
;
import
com.qiniu.storage.model.
DefaultPut
Ret
;
import
com.qiniu.storage.model.
Fetch
Ret
;
import
com.qiniu.util.Auth
;
import
com.qiniu.util.StringMap
;
import
com.qiniu.util.UrlSafeBase64
;
...
...
@@ -37,6 +39,8 @@ public class QNUploadServiceImpl implements IQNUploadService {
// 用于七牛云上传的bucket
private
Map
<
String
,
String
>
bucketList
;
private
static
final
Configuration
cfg
=
new
Configuration
(
Zone
.
zone0
());
@PostConstruct
public
void
init
()
{
auth
=
Auth
.
create
(
accessKey
,
secretKey
);
...
...
@@ -76,7 +80,7 @@ public class QNUploadServiceImpl implements IQNUploadService {
//Configuration c = new Configuration(z);
//实例化一个BucketManager对象
BucketManager
bucketManager
=
new
BucketManager
(
auth
);
BucketManager
bucketManager
=
new
BucketManager
(
auth
,
cfg
);
//文件保存的空间名和文件名
String
bucket
=
"yhb-img01"
;
...
...
@@ -87,7 +91,7 @@ public class QNUploadServiceImpl implements IQNUploadService {
try
{
//调用fetch方法抓取文件
DefaultPut
Ret
fetch
=
bucketManager
.
fetch
(
url
,
bucket
,
key
);
Fetch
Ret
fetch
=
bucketManager
.
fetch
(
url
,
bucket
,
key
);
//fetch.
...
...
@@ -106,7 +110,7 @@ public class QNUploadServiceImpl implements IQNUploadService {
String
SECRET_KEY
=
"pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm"
;
Auth
auth
=
Auth
.
create
(
ACCESS_KEY
,
SECRET_KEY
);
//新建一个OperationManager对象
OperationManager
operater
=
new
OperationManager
(
auth
);
OperationManager
operater
=
new
OperationManager
(
auth
,
cfg
);
//设置要转码的空间和key,并且这个key在你空间中存在
String
bucket
=
"yhb-img01"
;
String
key
=
"ufo/live/m3u8/yohotest14.m3u8"
;
// 14 4 分钟 15 3分钟
...
...
@@ -119,12 +123,17 @@ public class QNUploadServiceImpl implements IQNUploadService {
//可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。
String
urlbase64
=
UrlSafeBase64
.
encodeToString
(
"yhb-img01:ufo/live/mp4/test25.mp4"
);
String
pfops
=
fops
+
"|saveas/"
+
urlbase64
;
//设置pipeline参数
//设置pipeline参数
http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/live/ufo_avthumb_notify
StringMap
params
=
new
StringMap
().
putWhen
(
"force"
,
1
,
true
).
putNotEmpty
(
"pipeline"
,
pipeline
);
//.put("notifyURL", "http://testapi.yohops.com/live/ufo_avthumb_notify");
try
{
String
persistid
=
operater
.
pfop
(
bucket
,
key
,
pfops
,
params
);
//打印返回的persistid
System
.
out
.
println
(
persistid
);
OperationStatus
operationStatus
=
operater
.
prefop
(
persistid
);
System
.
out
.
println
(
operationStatus
.
code
);
}
catch
(
QiniuException
e
)
{
//捕获异常信息
Response
r
=
e
.
response
;
...
...
@@ -137,6 +146,8 @@ public class QNUploadServiceImpl implements IQNUploadService {
//ignore
}
}
}
public
String
getToken
(
String
bucket
)
{
...
...
@@ -150,7 +161,7 @@ public class QNUploadServiceImpl implements IQNUploadService {
String
fileMode
=
fileName
.
substring
(
15
,
17
);
String
key
=
bucket
+
fileName
;
UploadManager
uploadManager
=
new
UploadManager
();
UploadManager
uploadManager
=
new
UploadManager
(
cfg
);
Response
res
;
try
{
res
=
uploadManager
.
put
(
file
,
key
,
getToken
(
bucketList
.
get
(
fileMode
)));
...
...
@@ -173,7 +184,7 @@ public class QNUploadServiceImpl implements IQNUploadService {
@Override
public
void
copyFile
(
String
from_bucket
,
String
from_key
,
String
to_bucket
,
String
to_key
)
{
BucketManager
bucketManager
=
new
BucketManager
(
auth
);
BucketManager
bucketManager
=
new
BucketManager
(
auth
,
cfg
);
try
{
bucketManager
.
copy
(
from_bucket
,
from_key
,
to_bucket
,
to_key
);
}
catch
(
QiniuException
e
)
{
...
...
pom.xml
View file @
b4294bb
...
...
@@ -160,6 +160,12 @@
<dependency>
<groupId>
com.yoho.core
</groupId>
<artifactId>
yoho-core-redis-cluster
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.squareup.okio
</groupId>
<artifactId>
okio
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
...
...
web/pom.xml
View file @
b4294bb
...
...
@@ -46,6 +46,17 @@
<dependency>
<groupId>
com.yoho.ufo
</groupId>
<artifactId>
ufo-platform-common
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.qiniu
</groupId>
<artifactId>
qiniu-java-sdk
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.qiniu
</groupId>
<artifactId>
qiniu-java-sdk
</artifactId>
<version>
7.2.17
</version>
</dependency>
<dependency>
<groupId>
com.yoho.ufo
</groupId>
...
...
Please
register
or
login
to post a comment