public async Task <FocalPoint> GetFocalPoint() { AdageMediaService service = new AdageMediaService(); string root = HttpContext.Current.Server.MapPath("~/App_Data"); var provider = new MultipartFormDataStreamProvider(root); try { StringBuilder sb = new StringBuilder(); // Holds the response body // Read the form data and return an async task. await Request.Content.ReadAsMultipartAsync(provider); // This illustrates how to get the file names for uploaded files. foreach (var file in provider.FileData) { FileInfo fileInfo = new FileInfo(file.LocalFileName); sb.Append(string.Format("Uploaded file: {0} ({1} bytes)\n", fileInfo.Name, fileInfo.Length)); byte[] outputFileBytes = System.IO.File.ReadAllBytes(file.LocalFileName); return(await service.GetFocalPointByBytes(outputFileBytes)); } throw new ApplicationException("Expected file"); } catch (System.Exception e) { throw e; } }
private void MediaService_Saving(Umbraco.Core.Services.IMediaService sender, Umbraco.Core.Events.SaveEventArgs <Umbraco.Core.Models.IMedia> e) { foreach (var mediaItem in e.SavedEntities) { if (mediaItem.ContentType.Alias == "Image" && mediaItem.VersionId <= 1) { //perhaps send to Azure for AI analysis of image contents or something... AdageMediaService service = new AdageMediaService(); service.HandleImageUpload(mediaItem); } } }
public async Task <FocalPoint> GetFocalPoint(Byte[] bytes) { AdageMediaService service = new AdageMediaService(); return(await service.GetFocalPointByBytes(bytes)); }