/// <summary> /// Create a thumbnail image. /// </summary> /// <param name="request">Request. <see cref="PostExtractThumbnailRequest" /></param> /// <returns><see cref="ExtractThumbnailResponse"/></returns> public ExtractThumbnailResponse PostExtractThumbnail(PostExtractThumbnailRequest request) { // verify the required parameter 'name' is set if (request.Name == null) { throw new ApiException(400, "Missing required parameter 'name' when calling PostExtractThumbnail"); } // verify the required parameter 'destinationPath' is set if (request.DestinationPath == null) { throw new ApiException(400, "Missing required parameter 'destinationPath' when calling PostExtractThumbnail"); } // verify the required parameter 'offset' is set if (request.Offset == null) { throw new ApiException(400, "Missing required parameter 'offset' when calling PostExtractThumbnail"); } // create path and map variables var resourcePath = "/video/{name}/extractThumbnail?appSid={appSid}&destinationPath=[destinationPath]&offset=[offset]&folder=[folder]&storage=[storage]&destFileName=[destFileName]"; resourcePath = Regex .Replace(resourcePath, "\\*", string.Empty) .Replace("&", "&") .Replace("/?", "?"); resourcePath = this.AddPathParameter(resourcePath, "name", request.Name); resourcePath = this.AddQueryParameter(resourcePath, "destinationPath", request.DestinationPath); 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); try { var response = this.apiInvoker.InvokeApi( resourcePath, "POST", null, null, null); if (response != null) { return((ExtractThumbnailResponse)SerializationHelper.Deserialize(response, typeof(ExtractThumbnailResponse))); } return(null); } catch (ApiException ex) { if (ex.ErrorCode == 404) { return(null); } throw; } }
public void TestPostExtractThumbnail() { var localName = "sample.mp4"; var destPath = Path.Combine(this.dataFolder, "thumbnail.png"); var fullName = Path.Combine(this.dataFolder, localName); this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName)); var request = new PostExtractThumbnailRequest(localName, destPath, 1000, this.dataFolder); var actual = this.VideoApi.PostExtractThumbnail(request); Assert.AreEqual(200, System.Convert.ToInt32(actual.Code.ToString())); }