本文为您提供了服务端 Java SDK 的点播 CDN模块相关的 API 调用示例。主要包含:预热 URL、刷新 URL、查询 URL 预热刷新状态。
使用前请先完成初始化,参考 初始化
接口请求参数和返回参数详见 OpenAPI:预热 URL
import com.kuaishou.vod.core.Credential;
import com.kuaishou.vod.core.HttpProfile;
import com.kuaishou.vod.openapi.client.CdnClient;
import com.kuaishou.vod.openapi.model.request.cdn.PreloadRequest;
import com.kuaishou.vod.openapi.model.response.cdn.PreloadResponse;
public class Demo {
public static void main(String[] args) throws Exception {
HttpProfile profile = HttpProfile.getDefault();
Credential credential = new Credential(<分配的access_key_id>, <分配的secret_key>);
CdnClient client = new CdnClient(profile, credential);
PreloadRequest request = new PreloadRequest();
request.objectPath = "http://k.com/test.mp4";
PreloadResponse response = client.preload(request);
System.out.println("response=" + response.getResponseMeta().getRequestId());
}
}
接口请求参数和返回参数详见 OpenAPI:刷新 URL
import com.kuaishou.vod.core.Credential;
import com.kuaishou.vod.core.HttpProfile;
import com.kuaishou.vod.openapi.client.CdnClient;
import com.kuaishou.vod.openapi.model.request.cdn.PreloadRequest;
import com.kuaishou.vod.openapi.model.response.cdn.PreloadResponse;
public class Demo {
public static void main(String[] args) throws Exception {
HttpProfile profile = HttpProfile.getDefault();
Credential credential = new Credential(<分配的access_key_id>, <分配的secret_key>);
CdnClient client = new CdnClient(profile, credential);
RefreshRequest request = new RefreshRequest();
request.objectPath = "https://test.com/test.mp4";
request.objectType = "File";
RefreshResponse response = client.refresh(request);
System.out.println("response=" + response.getResponseMeta().getRequestId());
}
}
接口请求参数和返回参数详见 OpenAPI:查询CDN预热刷新状态
import com.kuaishou.vod.core.Credential;
import com.kuaishou.vod.core.HttpProfile;
import com.kuaishou.vod.openapi.client.CdnClient;
import com.kuaishou.vod.openapi.model.request.cdn.PreloadRequest;
import com.kuaishou.vod.openapi.model.response.cdn.PreloadResponse;
public class Demo {
public static void main(String[] args) throws Exception {
HttpProfile profile = HttpProfile.getDefault();
Credential credential = new Credential(<分配的access_key_id>, <分配的secret_key>);
CdnClient client = new CdnClient(profile, credential);
QueryStatusRequest request = new QueryStatusRequest();
request.taskId = "任务 ID";
request.taskType = "preload";
request.offset = 0;
request.limit = 1;
QueryStatusResponse response = client.queryStatus(request);
System.out.println("response=" + response.getResponseMeta().getRequestId());
}
}