最近更新时间:2024-08-15 11:05:42
git clone https://github.com/KscSDK/ksc-sdk-java.git
mvn clean install
<dependencies>
<dependency>
<groupId>com.ksyun</groupId>
<artifactId>ksc-sdk-java-kvs</artifactId>
<version>0.3.21</version>
</dependency>
</dependencies>
~/.aws/credentials on Linux, OS X or unix
C:\Users\USERNAME\.aws\credentials on Windows
[default]
aws_access_key_id = your_access_key_id
aws_secret_access_key = your_secret_access_key
AWSCredentials credentials = new BasicAWSCredentials(aws_access_key_id, aws_secret_access_key);
KSCKVSJsonClient ksc = new KSCKVSJsonClient();
//可传入AWSCredentials参数 如:KSCKVSJsonClient ksc = new KSCKVSJsonClient(credentials);
ksc.setEndpoint("http://kvs.cn-beijing-6.api.ksyun.com/");
字符集:utf-8
接口名
Preset
调用方式
PresetRequest presetRequest = new PresetRequest();
String data = PresetSet("xxx");
presetRequest.setData(data);
KvsErrResult presetResult = ksc.Preset(presetRequest);
//请求内容生成接口
private static String PresetSet(String preset) throws JSONException {
String presettype = "xxx";
JSONObject data = new JSONObject();
JSONObject param = new JSONObject();
JSONObject video = new JSONObject();
JSONObject audio = new JSONObject();
JSONArray logos = new JSONArray();
data.put("Preset", "xxx");
data.put("PresetType", "xxx");
data.put("Description", "xxx");
video.put("vr", "13");
video.put("vb", "780000");
video.put("vcodec", "h264");
for (int i = 0; i < 4; i++) {
JSONArray logo = new JSONArray();
for (int j = 0; j < 2; j++) {
JSONObject tmp = new JSONObject();
tmp.put("url", String.valueOf(i) + ":" + String.valueOf(j));
tmp.put("ss", i + j);
logo.put(tmp);
}
logos.put(logo);
}
audio.put("ar", "xxx");
audio.put("ab", "xxx");
audio.put("acodec", "aac");
audio.put("an", 0);
param.put("f", "xxx");
param.put("VIDEO", video);
param.put("AUDIO", audio);
param.put("LOGOS", logos);
data.put("Param", param);
return data.toString();
}
接口名
UpdatePreset
调用方式
UpdatePresetRequest presetRequest = new UpdatePresetRequest();
String data = PresetSet("xxx");
presetRequest.setData(data1);
KvsErrResult presetResult = ksc.UpdatePreset(presetRequest);
接口名
DelPreset
调用方式
DeletePresetRequest deletePresetRequest = new DeletePresetRequest();
deletePresetRequest.setPreset("xxx");
KvsErrResult deletePresetResult = ksc.DelPreset(deletePresetRequest);
接口名
GetPresetList
调用方式
GetListRequest gitlistrequest = new GetListRequest();
gitlistrequest.setWithDetail(1);
GetPresetListResult getpresetlistResult = ksc.GetPresetList(gitlistrequest);
接口名
GetPresetDetail
调用方式
GetPresetDetailRequest getPresetDetailRequest = new GetPresetDetailRequest();
getPresetDetailRequest.setPreset("xxx");
GetPresetDetailResult getPresetDetailResult = ksc.GetPresetDetail(getPresetDetailRequest);
接口名
CreateTask
调用方式
CreateTaskRequest createTaskRequest = new CreateTaskRequest();
String data2 = setTask("xxx", "xxx", "xxx", "xxx");
createTaskRequest.setData(data2);
CreateTasklResult createTasklResult = ksc.CreateTask(createTaskRequest);
//请求内容生成接口
private static String setTask(String preset, String dst_bucket, String dst_object_key, String src_object_key)
throws JSONException {
JSONObject data = new JSONObject();
data.put("Preset", preset);
data.put("SrcInfo", TaskSrcInfo(dst_bucket, src_object_key));
data.put("DstBucket", dst_bucket);
data.put("DstObjectKey", dst_object_key);
data.put("DstDir", "");
data.put("IsTop", 0);
data.put("DstAcl", "public-read");
data.put("CbUrl", "");
data.put("CbMethod", "POST");
data.put("ExtParam", "");
return data.toString();
}
接口名
TopTaskByTaskID
调用方式
TopTaskByTaskIDRequest topTaskByTaskIDRequest = new TopTaskByTaskIDRequest();
topTaskByTaskIDRequest.setTaskID("xxx");
KvsErrResult TopTaskByTaskIDResult = ksc.TopTaskByTaskID(topTaskByTaskIDRequest);
接口名
DelTaskByTaskID
调用方式
DelTaskByTaskIDRequest delTaskByTaskIDRequest = new DelTaskByTaskIDRequest();
delTaskByTaskIDRequest.setTaskID("xxx");
KvsErrResult DelTaskByTaskIDResult = ksc.DelTaskByTaskID(delTaskByTaskIDRequest);
接口名
GetTaskList
调用方式
GetTaskListRequest getTaskListRequest = new GetTaskListRequest();
getTaskListRequest.setStartDate(20200202);
getTaskListRequest.setEndDate(20200220);
getTaskListRequest.setTaskStatus("succ");
getTaskListRequest.setErrorCode("3255");
GetTaskListResult getTaskListResult = ksc.GetTaskList(getTaskListRequest);
接口名
GetTaskByTaskID
调用方式
GetTaskByTaskIDRequest getTaskByTaskIDRequest = new GetTaskByTaskIDRequest();
getTaskByTaskIDRequest.setTaskID("xxx");
GetTaskByTaskIDResult getTaskByTaskIDResult = ksc.GetTaskByTaskID(getTaskByTaskIDRequest);
接口名
QueryPipeline
调用方式
QueryPipelineRequest queryPipelineRequest = new QueryPipelineRequest();
queryPipelineRequest.setPipelineName("usual");
QueryPipelineResult queryPipelineResult = ksc.QueryPipeline(queryPipelineRequest);
System.out.println(queryPipelineResult);
接口名
UpdatePipeline
调用方式
UpdatePipelineRequest updatePipelineRequest = new UpdatePipelineRequest();
updatePipelineRequest.setData(setPipeline("usual"));
KvsErrResult updatePipelineResult = ksc.UpdatePipeline(updatePipelineRequest);
System.out.println(updatePipelineResult); //设置更新任务队列请求参数 private static String setPipeline(String PipelineName) { JSONObject data = new JSONObject(); data.put("PipelineName", PipelineName); data.put("State", "Active"); return data.toString(); }
接口名
GetTaskMetaInfo
调用方式
GetTaskMetaRequest getTaskMetaInfoRequest = new GetTaskMetaRequest();
getTaskMetaInfoRequest.setTaskID("xxx"); //需要是avinfo模板类型的任务
getTaskMetaInfoRequest.setStartDate(20200202);
GetTaskMetaResult getTaskMetaResult = ksc.GetTaskMetaInfo(getTaskMetaInfoRequest);
System.out.println(getTaskMetaResult);
接口名
FetchMetaInfo
调用方式
JSONObject data = new JSONObject();
data.put("SrcPath","bkt-bj-youpin-video-kscn/daren/b911aecedd47b97b8d3c1214c758d62e.mp4");
System.out.println(data);
FetchMetaInfoRequest fetchMetaInfoRequest = new FetchMetaInfoRequest();
fetchMetaInfoRequest.setData(data.toString());
FetchMetaInfoResult fetchMetaInfoResult = ksc.FetchMetaInfo(fetchMetaInfoRequest);
System.out.println(fetchMetaInfoResult.getMetaInfo());
纯净模式