/// <summary> /// Converts the Getty images data into a JSON-serializable object. /// </summary> /// <param name="img"></param> /// <returns></returns> public static GettyImage CreateJsonGettyImage(Image img) { var ji = new GettyImage { Id = img.ImageId, Title = img.Title, Tags = img.ImageFamily, UrlThumb = img.UrlThumb, UrlPreview = img.UrlPreview }; return(ji); }
/// <summary> /// Converts the Getty images data into a JSON-serializable object. /// </summary> /// <param name="img"></param> /// <returns></returns> public static GettyImage CreateJsonGettyImageClient(GettyImage img) { var ji = new GettyImage { Id = img.Id, GettyImageId = img.GettyImageId, Title = img.Title, Tags = img.Tags, UrlThumb = img.UrlThumb, UrlPreview = img.UrlPreview }; return(ji); }
/// <summary> /// Upload image to Kaltural /// </summary> /// <param name="gettyImage"></param> /// <returns></returns> public string UploadToKaltural(GettyImage gettyImage) { try{ //Upload to kaltural var fullPath = DownloadImage(gettyImage.UrlPreview, string.Format("{0}{1}.jpg", gettyImage.UserId, gettyImage.Id)); var fileName = string.Format("{0}{1}_{2}", gettyImage.UserId, gettyImage.Id, DateTime.UtcNow.ToString("ddMMyyyyhmmss")); var fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read); var kalturaMediaEntry = KalturaService.StartSessionAndUploadMedia(fileStream, KalturaMediaType.IMAGE, fileName); fileStream.Flush(); fileStream.Close(); DeleteFile(fullPath); return(kalturaMediaEntry.Id); } catch (Exception) { //Write log here //LogHelper.Error("Save image is fail: ", ex); return(null); } }
/// <summary> /// Insert Gettty Images Client /// </summary> /// <param name="gettyImage"></param> /// <returns></returns> public int InsertGetttyImagesClient(GettyImage gettyImage) { var imageResults = BlogService.InsertGettyImages(gettyImage); return(imageResults); }