前置条件

初始化

点播服务的接入区域参考接入区域标识,例如:接入区域在上海,请使用cn-shanghai

  • 使用账号AccessKey初始化。
    import com.aliyuncs.profile.DefaultProfile;
    import com.aliyuncs.DefaultAcsClient;
    import com.aliyuncs.exceptions.ClientException;
    
    public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException {
    	String regionId = "cn-shanghai";  // 点播服务接入区域
    	DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
    	DefaultAcsClient client = new DefaultAcsClient(profile);
    	return client;
    }
    			
  • 使用STS初始化。
    import com.aliyuncs.profile.DefaultProfile;
    import com.aliyuncs.DefaultAcsClient;
    import com.aliyuncs.exceptions.ClientException;
    
    public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret, String securityToken) throws ClientException {
    	String regionId = "cn-shanghai";  // 点播服务接入区域
    	DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret, securityToken);
    	DefaultAcsClient client = new DefaultAcsClient(profile);
    	return client;
    }