private void UploadImage(UploadArgs args, HttpPostedFile file, string krakedImgePath) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(file, "file"); var newFile = DownloadAndCreateFile(krakedImgePath, file); if (newFile == null) { base.Process(args); } else { bool flag = UploadProcessor.IsUnpack(args, newFile); var altText = args.GetFileParameter(file.FileName, "alt"); MediaUploader mediaUploader = new MediaUploader { File = newFile, Unpack = flag, Folder = args.Folder, Versioned = args.Versioned, Language = args.Language, AlternateText = !(string.IsNullOrEmpty(altText)) ? altText : file.FileName, Overwrite = args.Overwrite, FileBased = args.Destination == UploadDestination.File }; System.Collections.Generic.List <MediaUploadResult> list; using (new SecurityDisabler()) { list = mediaUploader.Upload(); } Log.Audit(this, "Upload: {0}", new string[] { file.FileName }); foreach (MediaUploadResult current in list) { this.ProcessItem(args, current.Item, current.Path); } } }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> /// <exception cref="T:System.Exception"><c>Exception</c>.</exception> public void Process(UploadArgs args) { Assert.ArgumentNotNull(args, "args"); for (int i = 0; i < args.Files.Count; i++) { HttpPostedFile httpPostedFile = args.Files[i]; if (!string.IsNullOrEmpty(httpPostedFile.FileName)) { try { bool flag = UploadProcessor.IsUnpack(args, httpPostedFile); if (args.FileOnly) { if (flag) { Save.UnpackToFile(args, httpPostedFile); } else { string filename = this.UploadToFile(args, httpPostedFile); if (i == 0) { args.Properties["filename"] = FileHandle.GetFileHandle(filename); } } } else { MediaUploader mediaUploader = new MediaUploader { File = httpPostedFile, Unpack = flag, Folder = args.Folder, Versioned = args.Versioned, Language = args.Language, AlternateText = args.GetFileParameter(httpPostedFile.FileName, "alt"), Overwrite = args.Overwrite, FileBased = args.Destination == UploadDestination.File }; System.Collections.Generic.List <MediaUploadResult> list; using (new SecurityDisabler()) { list = mediaUploader.Upload(); } Log.Audit(this, "Upload: {0}", new string[] { httpPostedFile.FileName }); foreach (MediaUploadResult current in list) { this.ProcessItem(args, current.Item, current.Path); } } } catch (System.Exception exception) { Log.Error("Could not save posted file: " + httpPostedFile.FileName, exception, this); throw; } } } }