Esempio n. 1
0
        public void TestGetVideoProperties()
        {
            var localName  = "sample.avi";
            var remoteName = "TestGetVideo.avi";
            var fullName   = Path.Combine(this.dataFolder, remoteName);

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));
            var request = new GetVideoPropertiesRequest(remoteName, this.dataFolder);
            var actual  = this.VideoApi.GetVideoProperties(request);

            Assert.AreEqual(200, System.Convert.ToInt32(actual.Code.ToString()));
            Assert.IsNotNull(actual.VideoProperties.List);
        }
        public void TestHandleErrors()
        {
            string name = "noFileWithThisName.avi";

            try
            {
                var request = new GetVideoPropertiesRequest(name);
                this.VideoApi.GetVideoProperties(request);

                Assert.Fail("Excpected exception has not been throwed");
            }
            catch (ApiException apiException)
            {
                Assert.AreEqual(400, apiException.ErrorCode);
                Assert.IsTrue(apiException.Message.StartsWith("Error while loading file 'noFileWithThisName.avi' from storage:"), "Current message: " + apiException.Message);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Read video properties info.
        /// </summary>
        /// <param name="request">Request. <see cref="GetVideoPropertiesRequest" /></param>
        /// <returns><see cref="VideoPropertiesResponse"/></returns>
        public VideoPropertiesResponse GetVideoProperties(GetVideoPropertiesRequest request)
        {
            // verify the required parameter 'name' is set
            if (request.Name == null)
            {
                throw new ApiException(400, "Missing required parameter 'name' when calling GetVideoProperties");
            }

            // create path and map variables
            var resourcePath = "/video/{name}/videoProperties?appSid={appSid}&amp;folder=[folder]&amp;storage=[storage]";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = this.AddPathParameter(resourcePath, "name", request.Name);
            resourcePath = this.AddQueryParameter(resourcePath, "folder", request.Folder);
            resourcePath = this.AddQueryParameter(resourcePath, "storage", request.Storage);

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

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

                throw;
            }
        }