public void TestPostExtractVideo()
        {
            var localName  = "sample.mp4";
            var resultPath = Path.Combine(this.dataFolder, "extracted.mp4");
            var fullName   = Path.Combine(this.dataFolder, localName);

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));

            var request = new PostExtractVideoRequest(localName, resultPath, 1000, 4000, this.dataFolder);
            var actual  = this.VideoApi.PostExtractVideo(request);

            Assert.AreEqual(200, System.Convert.ToInt32(actual.Code.ToString()));
        }
Exemple #2
0
        /// <summary>
        /// Extract video.
        /// </summary>
        /// <param name="request">Request. <see cref="PostExtractVideoRequest" /></param>
        /// <returns><see cref="ExtractVideoResponse"/></returns>
        public ExtractVideoResponse PostExtractVideo(PostExtractVideoRequest request)
        {
            // verify the required parameter 'name' is set
            if (request.Name == null)
            {
                throw new ApiException(400, "Missing required parameter 'name' when calling PostExtractVideo");
            }

            // verify the required parameter 'destinationPath' is set
            if (request.DestinationPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'destinationPath' when calling PostExtractVideo");
            }

            // verify the required parameter 'start' is set
            if (request.Start == null)
            {
                throw new ApiException(400, "Missing required parameter 'start' when calling PostExtractVideo");
            }

            // verify the required parameter 'offset' is set
            if (request.Offset == null)
            {
                throw new ApiException(400, "Missing required parameter 'offset' when calling PostExtractVideo");
            }

            // create path and map variables
            var resourcePath = "/video/{name}/extract?appSid={appSid}&amp;destinationPath=[destinationPath]&amp;start=[start]&amp;offset=[offset]&amp;folder=[folder]&amp;storage=[storage]&amp;destFileName=[destFileName]&amp;fontsLocation=[fontsLocation]";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = this.AddPathParameter(resourcePath, "name", request.Name);
            resourcePath = this.AddQueryParameter(resourcePath, "destinationPath", request.DestinationPath);
            resourcePath = this.AddQueryParameter(resourcePath, "start", request.Start);
            resourcePath = this.AddQueryParameter(resourcePath, "offset", request.Offset);
            resourcePath = this.AddQueryParameter(resourcePath, "folder", request.Folder);
            resourcePath = this.AddQueryParameter(resourcePath, "storage", request.Storage);
            resourcePath = this.AddQueryParameter(resourcePath, "destFileName", request.DestFileName);
            resourcePath = this.AddQueryParameter(resourcePath, "fontsLocation", request.FontsLocation);

            try
            {
                var response = this.apiInvoker.InvokeApi(
                    resourcePath,
                    "POST",
                    null,
                    null,
                    null);
                if (response != null)
                {
                    return((ExtractVideoResponse)SerializationHelper.Deserialize(response, typeof(ExtractVideoResponse)));
                }

                return(null);
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }

                throw;
            }
        }