本文为您提供了服务端 Java SDK 的媒资上传模块相关的 API 调用示例。主要包含:URL拉取上传媒资。
使用前请先完成初始化,参考 初始化
接口请求参数和返回参数详见 OpenAPI:URL拉取上传媒资
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.kuaishou.vod.core.Credential;
import com.kuaishou.vod.core.HttpProfile;
import com.kuaishou.vod.openapi.client.VodClient;
import com.kuaishou.vod.openapi.model.request.vod.FetchUploadRequest;
import com.kuaishou.vod.openapi.model.response.vod.FetchUploadResponse;
public class Demo {
public static void main(String[] args) throws Exception {
HttpProfile profile = HttpProfile.getDefault();
Credential credential = new Credential(<分配的access_key_id>, <分配的secret_key>);
VodClient client = new VodClient(profile, credential);
FetchUploadRequest request = new FetchUploadRequest();
JsonArray jsonArray = new JsonArray();
JsonObject object1 = new JsonObject();
object1.addProperty("SourceURL", "https://xxx.com/test.mp4");
object1.addProperty("CallbackArgs", "test");
jsonArray.add(object1);
request.urlSets = jsonArray.toString();
FetchUploadResponse response = client.fetchUpload(request);
System.out.println("response=" + response.getResponseMeta());
}
}