FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-sdk/examples/fops.java at master · CDNCloud-com/java-sdk · GitHub
CDNCloud-com
/
java-sdk
Public
forked from
qiniu/java-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-sdk
/
examples
/
fops.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (48 loc) · 2.04 KB
Breadcrumbs
java-sdk
/
examples
/
fops.java
Copy path
File metadata and controls
53 lines (48 loc) · 2.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import
com
.
qiniu
.
common
.
QiniuException
;
import
com
.
qiniu
.
http
.
Response
;
import
com
.
qiniu
.
processing
.
OperationManager
;
import
com
.
qiniu
.
util
.
Auth
;
import
com
.
qiniu
.
util
.
StringMap
;
import
com
.
qiniu
.
util
.
UrlSafeBase64
;
import
com
.
qiniu
.
common
.
Zone
;
import
com
.
qiniu
.
storage
.
Configuration
;
public
class
OperateDemo
{
public
static
void
main
(
String
[]
args
)
throws
QiniuException
{
//设置账号的AK,SK
String
ACCESS_KEY
=
"Access_Key"
;
String
SECRET_KEY
=
"Secret_Key"
;
Auth
auth
=
Auth
.
create
(
ACCESS_KEY
,
SECRET_KEY
);
Zone
z
=
Zone
.
zone0
();
Configuration
c
=
new
Configuration
(
z
);
//新建一个OperationManager对象
OperationManager
operater
=
new
OperationManager
(
auth
,
c
);
//设置要转码的空间和key,并且这个key在你空间中存在
String
bucket
=
"Bucket_Name"
;
String
key
=
"Bucket_key"
;
//设置转码操作参数
String
fops
=
"avthumb/mp4/s/640x360/vb/1.25m"
;
//设置转码的队列
String
pipeline
=
"yourpipelinename"
;
//可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。
String
urlbase64
=
UrlSafeBase64
.
encodeToString
(
"目标Bucket_Name:自定义文件key"
);
String
pfops
=
fops
+
"|saveas/"
+
urlbase64
;
//设置pipeline参数
StringMap
params
=
new
StringMap
().
putWhen
(
"force"
,
1
,
true
).
putNotEmpty
(
"pipeline"
,
pipeline
);
try
{
String
persistid
=
operater
.
pfop
(
bucket
,
key
,
pfops
,
params
);
//打印返回的persistid
System
.
out
.
println
(
persistid
);
}
catch
(
QiniuException
e
) {
//捕获异常信息
Response
r
=
e
.
response
;
// 请求失败时简单状态信息
System
.
out
.
println
(
r
.
toString
());
try
{
// 响应的文本信息
System
.
out
.
println
(
r
.
bodyString
());
}
catch
(
QiniuException
e1
) {
//ignore
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL