public async Task <GenerateVideoCoverResponse> GenerateVideoCoverAdvanceAsync(GenerateVideoCoverAdvanceRequest request, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime) { // Step 0: init client string accessKeyId = await this._credential.GetAccessKeyIdAsync(); string accessKeySecret = await this._credential.GetAccessKeySecretAsync(); AlibabaCloud.RPCClient.Models.Config authConfig = new AlibabaCloud.RPCClient.Models.Config { AccessKeyId = accessKeyId, AccessKeySecret = accessKeySecret, Type = "access_key", Endpoint = "openplatform.aliyuncs.com", Protocol = _protocol, RegionId = _regionId, }; AlibabaCloud.SDK.OpenPlatform20191219.Client authClient = new AlibabaCloud.SDK.OpenPlatform20191219.Client(authConfig); AlibabaCloud.SDK.OpenPlatform20191219.Models.AuthorizeFileUploadRequest authRequest = new AlibabaCloud.SDK.OpenPlatform20191219.Models.AuthorizeFileUploadRequest { Product = "videorecog", RegionId = _regionId, }; AlibabaCloud.SDK.OpenPlatform20191219.Models.AuthorizeFileUploadResponse authResponse = await authClient.AuthorizeFileUploadAsync(authRequest, runtime); // Step 1: request OSS api to upload file AlibabaCloud.OSS.Models.Config ossConfig = new AlibabaCloud.OSS.Models.Config { AccessKeyId = authResponse.AccessKeyId, AccessKeySecret = accessKeySecret, Type = "access_key", Endpoint = AlibabaCloud.Commons.Common.GetEndpoint(authResponse.Endpoint, authResponse.UseAccelerate, _endpointType), Protocol = _protocol, RegionId = _regionId, }; AlibabaCloud.OSS.Client ossClient = new AlibabaCloud.OSS.Client(ossConfig); AlibabaCloud.SDK.TeaFileform.Models.FileField fileObj = new AlibabaCloud.SDK.TeaFileform.Models.FileField { Filename = authResponse.ObjectKey, Content = request.VideoUrlObject, ContentType = "", }; AlibabaCloud.OSS.Models.PostObjectRequest.PostObjectRequestHeader ossHeader = new AlibabaCloud.OSS.Models.PostObjectRequest.PostObjectRequestHeader { AccessKeyId = authResponse.AccessKeyId, Policy = authResponse.EncodedPolicy, Signature = authResponse.Signature, Key = authResponse.ObjectKey, File = fileObj, SuccessActionStatus = "201", }; AlibabaCloud.OSS.Models.PostObjectRequest uploadRequest = new AlibabaCloud.OSS.Models.PostObjectRequest { BucketName = authResponse.Bucket, Header = ossHeader, }; AlibabaCloud.OSSUtil.Models.RuntimeOptions ossRuntime = new AlibabaCloud.OSSUtil.Models.RuntimeOptions(); AlibabaCloud.Commons.Common.Convert(runtime, ossRuntime); await ossClient.PostObjectAsync(uploadRequest, ossRuntime); // Step 2: request final api GenerateVideoCoverRequest generateVideoCoverreq = new GenerateVideoCoverRequest(); AlibabaCloud.Commons.Common.Convert(request, generateVideoCoverreq); generateVideoCoverreq.VideoUrl = "http://" + authResponse.Bucket + "." + authResponse.Endpoint + "/" + authResponse.ObjectKey; GenerateVideoCoverResponse generateVideoCoverResp = await GenerateVideoCoverAsync(generateVideoCoverreq, runtime); return(generateVideoCoverResp); }
public async Task <GenerateVideoCoverResponse> GenerateVideoCoverAsync(GenerateVideoCoverRequest request, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime) { AlibabaCloud.TeaUtil.Common.ValidateModel(request); return(TeaModel.ToObject <GenerateVideoCoverResponse>(await DoRequestAsync("GenerateVideoCover", "HTTPS", "POST", "2020-03-20", "AK", null, request.ToMap(), runtime))); }