logologo
售前咨询
点播云
产品简介
购买指南
快速入门
控制台指南
服务端API
SDK文档
播放器SDK
上传SDK
服务端SDK
接入指引
Java SDK
相关协议
文档中心
SDK文档服务端SDKJava SDK点播 CDN

点播 CDN


本文为您提供了服务端 Java SDK 的点播 CDN模块相关的 API 调用示例。主要包含:预热 URL、刷新 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());
    }
}


刷新 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);

        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());
    }
}


查询CDN预热刷新状态

接口请求参数和返回参数详见 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());
    }
}

上一篇:媒体处理下一篇:数据统计
该篇文档内容是否对您有帮助?
有帮助没帮助