public static async Task <ConsoleOutput> CreateGif(this GifUpload upload, UploadConfig config, IHostingEnvironment env, AppDbContext db) { var gif = upload.Video.GenerateGifUpload(config.DirectoryBasePath, config.UrlBasePath); upload.Options.CompleteGifOptions(upload.Video, gif, env); upload.Options.CreateTempDirectory(); var result = await upload.Options.ConvertToGif(); if (!result.HasError) { upload.Options.DeleteTempDirectory(); gif.Size = gif.Path.GetFileLength(); await gif.SaveGif(db); } else if (result.HasError && string.IsNullOrEmpty(result.Error)) { result.Error = "An unidentified error occurred during conversion"; upload.Options.DeleteTempDirectory(); } return(result); }
public async Task <ConsoleOutput> CreateGif([FromBody] GifUpload upload) => await upload.CreateGif(config, env, db);