public bool UploadNCreate(FileUpload fileUpload, HttpFileCollection files, string albumID) { bool flag = true; bool result; try { if (fileUpload.PostedFile != null && fileUpload.PostedFile.ContentLength != 0) { if (string.IsNullOrEmpty(albumID)) { this.PageErrorMsg = "You should choose album for uploading"; result = false; return result; } if (!this.IsMimeTypeAllowed(fileUpload.PostedFile.ContentType, PhotoAlbumConstants.allowedMimeTypes)) { this.PageErrorMsg = "You should upload only jpeg, jpg images or zip archives"; result = false; return result; } using (new SecurityDisabler()) { Item item = this.CurrentMediaFolder; UploadArgs uploadArgs = new UploadArgs(); uploadArgs.Files = files; uploadArgs.Folder = item.Paths.Path; uploadArgs.Overwrite = false; uploadArgs.Unpack = true; uploadArgs.Versioned = false; uploadArgs.Language = Context.Language; uploadArgs.Destination = UploadDestination.Database; Context.SetActiveSite("shell"); try { if (PipelineFactory.GetPipeline("uiUpload") != null && PipelineFactory.GetPipeline("uiUpload").Processors != null) { foreach (Processor p in from Processor p in PipelineFactory.GetPipeline("uiUpload").Processors where p.Name.Equals("Sitecore.Pipelines.Upload.Done,Sitecore.Kernel,Process") select p) { PipelineFactory.GetPipeline("uiUpload").Processors.Remove(p); } } } catch (Exception exception) { Log.Error("Delete from Pipelines ", exception, this); } PipelineFactory.GetPipeline("uiUpload").Start(uploadArgs); if (uploadArgs.UploadedItems.Count == 1) { PhotoAlbumObject.PublishOneItem(uploadArgs.UploadedItems[0]); } else { if (uploadArgs.UploadedItems.Count > 1) { PhotoAlbumObject.PublishOneItem(uploadArgs.UploadedItems[0].Parent); } } foreach (Item current in uploadArgs.UploadedItems) { current.Editing.BeginEdit(); if (current.Fields["alt"] != null) { current.Fields["alt"].Value = current.Name; } current.Editing.EndEdit(); } Context.SetActiveSite("website"); Item item2 = Factory.GetDatabase(this.DbName).Items[albumID]; Item itemTemplate = Factory.GetDatabase(this.DbName).Items[PhotoAlbumConstants.photoTemplateID]; foreach (Item current2 in uploadArgs.UploadedItems) { string itemName2 = this.CheckExistingItemName(item2, current2.Name, false); this.CreateAndFillItem(itemName2, new Hashtable { { "Title", current2.Name }, { "image", current2 } }, item2, itemTemplate, false); } this.CurrentAlbumItem = item2; result = flag; return result; } } this.PageErrorMsg = "You should choose zip archive or image"; result = false; } catch (Exception exception) { Log.Error("Cannot upload image(s)", exception, this); result = false; } return result; }
public void Execute(UploadArgs args) { string dest = Path.ChangeExtension(args.Repo, "zip"); Console.WriteLine($"Zipping {args.Repo} to {dest} ..."); ZipFile.CreateFromDirectory(args.Repo, dest); }
/// <summary> /// Uses Verndale.CognitiveImageTagging services to analyze the image and provide possible captions. /// Assigns the first caption to the Alt field in the Image section upon execution of the command. /// Reference should be placed above "Done" and below "Save" in uiUpload Processor /// </summary> public void Process(UploadArgs args) { Assert.ArgumentNotNull((object)args, nameof(args)); var list = args.UploadedItems; Log.Info($"Verndale.Feature.CognitiveImageTagging: Upload Pipeline: processing AI Image Tags for {list.Count} images", this); foreach (var item in list) { if (item == null || !item.IsImage(out var mediaItem)) { continue; } var text = mediaItem.GetAltTextFromAI(); using (new SecurityDisabler()) { using (new EditContext(mediaItem)) { mediaItem.InnerItem.Fields["Alt"].Value = text; } } } Log.Info($"Verndale.CognitiveImageTagging: Ending AddImageAltText in uiUpload processor", this); }
/// <summary> /// Unpacks to file. /// </summary> /// <param name="args">The arguments.</param> /// <param name="file">The file.</param> private static void UnpackToFile(UploadArgs args, HttpPostedFile file) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(file, "file"); var filename = FileUtil.MapPath(TempFolder.GetFilename("temp.zip")); file.SaveAs(filename); using (var zipReader = new ZipReader(filename)) { foreach (var zipEntry in zipReader.Entries) { var str = FileUtil.MakePath(args.Folder, zipEntry.Name, '\\'); if (zipEntry.IsDirectory) { Directory.CreateDirectory(str); } else { if (!args.Overwrite) str = FileUtil.GetUniqueFilename(str); Directory.CreateDirectory(Path.GetDirectoryName(str)); lock (FileUtil.GetFileLock(str)) FileUtil.CreateFile(str, zipEntry.GetStream(), true); } } } }
/// <summary>Unpacks to file.</summary> /// <param name="args">The arguments.</param> /// <param name="file">The file.</param> private static void UnpackToFile(UploadArgs args, HttpPostedFile file) { Assert.ArgumentNotNull((object)args, "args"); Assert.ArgumentNotNull((object)file, "file"); string filename = FileUtil.MapPath(TempFolder.GetFilename("temp.zip")); file.SaveAs(filename); using (ZipReader zipReader = new ZipReader(filename)) { foreach (ZipEntry entry in zipReader.Entries) { string str = FileUtil.MakePath(args.Folder, entry.Name, '\\'); if (entry.IsDirectory) { Directory.CreateDirectory(str); } else { if (!args.Overwrite) { str = FileUtil.GetUniqueFilename(str); } Directory.CreateDirectory(Path.GetDirectoryName(str)); lock (FileUtil.GetFileLock(str)) FileUtil.CreateFile(str, entry.GetStream(), true); } } } }
/// <summary> /// Unpacks to file. /// </summary> /// <param name="args">The arguments.</param> /// <param name="file">The file.</param> private static void UnpackToFile(UploadArgs args, HttpPostedFile file) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(file, "file"); string filename = FileUtil.MapPath(TempFolder.GetFilename("temp.zip")); file.SaveAs(filename); using (ZipReader zipReader = new ZipReader(filename)) { foreach (ZipEntry current in zipReader.Entries) { string text = FileUtil.MakePath(args.Folder, current.Name, '\\'); if (current.IsDirectory) { System.IO.Directory.CreateDirectory(text); } else { if (!args.Overwrite) { text = FileUtil.GetUniqueFilename(text); } System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(text)); lock (FileUtil.GetFileLock(text)) { FileUtil.CreateFile(text, current.GetStream(), true); } } } } }
public void Process(UploadArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.Destination == UploadDestination.Database && EnsureUploadAsFile(args.Folder)) { args.Destination = UploadDestination.File; } }
/// <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 (var index = 0; index < args.Files.Count; ++index) { var file = args.Files[index]; if (!string.IsNullOrEmpty(file.FileName)) { try { var flag = IsUnpack(args, file); if (args.FileOnly) { if (flag) { UnpackToFile(args, file); } else { var filename = UploadToFile(args, file); if (index == 0) { args.Properties["filename"] = FileHandle.GetFileHandle(filename); } } } else { var mediaUploader = new S3MediaUploader { File = file, Unpack = flag, Folder = args.Folder, Versioned = args.Versioned, Language = args.Language, AlternateText = args.GetFileParameter(file.FileName, "alt"), Overwrite = args.Overwrite, FileBased = args.Destination == UploadDestination.File }; List <S3MediaUploadResult> list; using (new SecurityDisabler()) list = mediaUploader.Upload(); Log.Audit(this, "Upload: {0}", file.FileName); foreach (var S3MediaUploadResult in list) { ProcessItem(args, S3MediaUploadResult.Item, S3MediaUploadResult.Path); } } } catch (Exception ex) { Log.Error("Could not save posted file: " + file.FileName, ex, this); throw; } } } }
public void Process(UploadArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.Destination == UploadDestination.File) { var helper = new PipelineHelper(); helper.StartMediaProcessorJob(args.UploadedItems, PipelineHelper.GetContainerNameFromArgs(args)); } }
/// <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 (var index = 0; index < args.Files.Count; ++index) { var file = args.Files[index]; if (!string.IsNullOrEmpty(file.FileName)) { try { var flag = IsUnpack(args, file); if (args.FileOnly) { if (flag) { UnpackToFile(args, file); } else { var filename = UploadToFile(args, file); if (index == 0) args.Properties["filename"] = FileHandle.GetFileHandle(filename); } } else { var mediaUploader = new S3MediaUploader { File = file, Unpack = flag, Folder = args.Folder, Versioned = args.Versioned, Language = args.Language, AlternateText = args.GetFileParameter(file.FileName, "alt"), Overwrite = args.Overwrite, FileBased = args.Destination == UploadDestination.File }; List<S3MediaUploadResult> list; using (new SecurityDisabler()) list = mediaUploader.Upload(); Log.Audit(this, "Upload: {0}", file.FileName); foreach (var S3MediaUploadResult in list) ProcessItem(args, S3MediaUploadResult.Item, S3MediaUploadResult.Path); } } catch (Exception ex) { Log.Error("Could not save posted file: " + file.FileName, ex, this); throw; } } } }
public new void Process(UploadArgs args) { if (Sitecore.UIUtil.IsIE()) { // We need to use the original functionality for IE base.Process(args); return; } Assert.ArgumentNotNull((object)args, "args"); if (args.Destination == UploadDestination.File) { return; } foreach (string index in (NameObjectCollectionBase)args.Files) { HttpPostedFile file = args.Files[index]; if (!string.IsNullOrEmpty(file.FileName)) { if (UploadProcessor.IsUnpack(args, file)) { ZipReader zipReader = new ZipReader(file.InputStream); try { foreach (ZipEntry zipEntry in zipReader.Entries) { if (!zipEntry.IsDirectory && zipEntry.Size > Settings.Media.MaxSizeInDatabase) { string text = file.FileName + "/" + zipEntry.Name; HttpContext.Current.Response.Write("<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.browser.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", 'ShowFileTooBig(" + StringUtil.EscapeJavascriptString(text) + ")')</script></head><body>Done</body></html>"); args.ErrorText = string.Format("The file \"{0}\" is too big to be uploaded. The maximum size for uploading files is {1}.", (object)text, (object)MainUtil.FormatSize(Settings.Media.MaxSizeInDatabase)); args.AbortPipeline(); return; } } } finally { file.InputStream.Position = 0L; } } else if ((long)file.ContentLength > Settings.Media.MaxSizeInDatabase) { string fileName = file.FileName; HttpContext.Current.Response.Write("<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.browser.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", 'ShowFileTooBig(" + StringUtil.EscapeJavascriptString(fileName) + ")')</script></head><body>Done</body></html>"); args.ErrorText = string.Format("The file \"{0}\" is too big to be uploaded. The maximum size for uploading files is {1}.", (object)fileName, (object)MainUtil.FormatSize(Settings.Media.MaxSizeInDatabase)); args.AbortPipeline(); break; } } } }
private static void Main(string[] args) { const string apiKey = "astrometrynetapikey"; const string file = "test.fit"; try { var client = new Client(apiKey); var res = client.Login(); Console.WriteLine("Login : "******"\nRA : " + calibrationResponse.ra); Console.WriteLine("Dec : " + calibrationResponse.dec); Console.WriteLine("radius : " + calibrationResponse.radius); Console.WriteLine(""); foreach (string obj in objectsInFieldResponse.objects_in_field) { Console.WriteLine(obj); } } else { Console.WriteLine("Status : " + jobStatusResponse.Result.status); } } catch (Exception e) { Console.WriteLine(e.Message); } finally { Console.ReadKey(); } }
/// <summary> /// Upload an image and start the analysis. /// </summary> /// <param name="file">The filename (including path) to upload</param> /// <param name="uploadArgs">Arguments for the solver. If <c>null</c> the default parameters will be used</param> /// <returns>Upload result</returns> /// <exception cref="AstrometryException">Exception raised in the following cases : <c>file</c> does not exist, the session is not initialized, something breaks during upload</exception> /// <seealso cref="UploadArgs"/> public UploadResponse Upload(string file, UploadArgs uploadArgs = null) { if (file == null) { throw new ArgumentNullException("file"); } if (!requestSender.Connected) { throw new AstrometryNotConnectedException("Service is not connected, call Login first"); } return(requestSender.Upload(file, uploadArgs)); }
public void Process(UploadArgs args) { if (args == null) { return; } foreach (var item in args.UploadedItems) { // Should replace this with a pipeline or similar var contentExtractor = new PdfContentExtractor(); contentExtractor.LoadItemWithMetaData(item); } }
public new void Process(UploadArgs args) { if (Sitecore.UIUtil.IsIE()) { // We need to use the original functionality for IE base.Process(args); return; } Assert.ArgumentNotNull((object)args, "args"); if (args.Destination == UploadDestination.File) return; foreach (string index in (NameObjectCollectionBase)args.Files) { HttpPostedFile file = args.Files[index]; if (!string.IsNullOrEmpty(file.FileName)) { if (UploadProcessor.IsUnpack(args, file)) { ZipReader zipReader = new ZipReader(file.InputStream); try { foreach (ZipEntry zipEntry in zipReader.Entries) { if (!zipEntry.IsDirectory && zipEntry.Size > Settings.Media.MaxSizeInDatabase) { string text = file.FileName + "/" + zipEntry.Name; HttpContext.Current.Response.Write("<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.browser.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", 'ShowFileTooBig(" + StringUtil.EscapeJavascriptString(text) + ")')</script></head><body>Done</body></html>"); args.ErrorText = string.Format("The file \"{0}\" is too big to be uploaded. The maximum size for uploading files is {1}.", (object)text, (object)MainUtil.FormatSize(Settings.Media.MaxSizeInDatabase)); args.AbortPipeline(); return; } } } finally { file.InputStream.Position = 0L; } } else if ((long)file.ContentLength > Settings.Media.MaxSizeInDatabase) { string fileName = file.FileName; HttpContext.Current.Response.Write("<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.browser.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", 'ShowFileTooBig(" + StringUtil.EscapeJavascriptString(fileName) + ")')</script></head><body>Done</body></html>"); args.ErrorText = string.Format("The file \"{0}\" is too big to be uploaded. The maximum size for uploading files is {1}.", (object)fileName, (object)MainUtil.FormatSize(Settings.Media.MaxSizeInDatabase)); args.AbortPipeline(); break; } } } }
/// <summary>Uploads to file.</summary> /// <param name="args">The arguments.</param> /// <param name="file">The file.</param> /// <returns>The name of the uploaded file</returns> private string UploadToFile(UploadArgs args, HttpPostedFile file) { Assert.ArgumentNotNull((object)args, "args"); Assert.ArgumentNotNull((object)file, "file"); string str = FileUtil.MakePath(args.Folder, Path.GetFileName(file.FileName), '\\'); if (!args.Overwrite) { str = FileUtil.GetUniqueFilename(str); } file.SaveAs(str); Log.Info("File has been uploaded: " + str, (object)this); return(Assert.ResultNotNull <string>(str)); }
/// <summary> /// Uploads to file. /// </summary> /// <param name="args">The arguments.</param> /// <param name="file">The file.</param> /// <returns>The name of the uploaded file</returns> private string UploadToFile(UploadArgs args, HttpPostedFile file) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(file, "file"); string text = FileUtil.MakePath(args.Folder, System.IO.Path.GetFileName(file.FileName), '\\'); if (!args.Overwrite) { text = FileUtil.GetUniqueFilename(text); } file.SaveAs(text); Log.Info("File has been uploaded: " + text, this); return(Assert.ResultNotNull <string>(text)); }
public void Process(UploadArgs args) { Assert.ArgumentNotNull((object)args, nameof(args)); if (args.Destination == UploadDestination.File) { return; } foreach (string file1 in args.Files) { HttpPostedFile file2 = args.Files[file1]; if (!string.IsNullOrEmpty(file2.FileName)) { if (UploadProcessor.IsUnpack(args, file2)) { ZipReader zipReader = new ZipReader(file2.InputStream); try { foreach (ZipEntry entry in zipReader.Entries) { if (!entry.IsDirectory && !UploadFileSettings.IsAllowedFile(entry.Name, entry.Size)) { string text = file2.FileName + "/" + entry.Name; args.UiResponseHandlerEx.FileTooBigForUpload(StringUtil.EscapeJavascriptString(text)); args.ErrorText = UploadFileSettings.FileErrorMessage(file2.FileName); args.AbortPipeline(); return; } } } finally { file2.InputStream.Position = 0L; } } else if (!UploadFileSettings.IsAllowedFile(file2)) { string fileName = file2.FileName; if (HttpContext.Current.Request.Url.AbsolutePath != "/sitecore/shell/api/sitecore/Media/Upload") { args.UiResponseHandlerEx.FileTooBigForUpload(StringUtil.EscapeJavascriptString(fileName)); } args.ErrorText = UploadFileSettings.FileErrorMessage(file2.FileName); args.AbortPipeline(); break; } } } }
public void Process(UploadArgs args) { var db = Sitecore.Context.ContentDatabase; var uploadPath = db.GetItem(args.Folder).Paths.ContentPath; if (!uploadPath.StartsWith(Path)) { // Not uploading to designated folder return; } foreach (var item in args.UploadedItems) { Sitecore.Diagnostics.Log.Info(string.Format("UPLOAD Pipeline :: Item for Upload, Name: {0}, Path: {1}", item.Name, item.Paths.FullPath), this); // Need to change template for this item? Sitecore.Resources.Media.Media media = Sitecore.Resources.Media.MediaManager.GetMedia(item); string mimeType = string.Empty; if (media != null) { Sitecore.Diagnostics.Log.Info(string.Format("UPLOAD Pipeline :: Item has a mediaItem, extension: {0}, MIME type: {1}", media.Extension, media.MimeType), this); mimeType = media.MimeType; } var changedTemplate = Templates.Where(t => t.Old.Equals(item.Template.FullName) && t.MimeType.ToLower() == mimeType.ToLower()).FirstOrDefault(); if (changedTemplate != null) { var newTemplate = db.Templates[changedTemplate.New]; try { item.ChangeTemplate(newTemplate); Sitecore.Diagnostics.Log.Info(string.Format("UPLOAD Pipeline :: Changed Template applied to item {0}: from [{1}] to [{2}].", item.Name, item.Template.FullName, newTemplate.FullName), this); } catch (Exception ex) { Sitecore.Diagnostics.Log.Error(string.Format("UPLOAD Pipeline :: Configured ChangeTemplate was unable to be applied on item {0}: original template [{1}], new template [{2}].", item.Name, item.Template.FullName, newTemplate.FullName), ex, this); } } } }
public new void Process(UploadArgs args) { if (Sitecore.UIUtil.IsIE()) { // We need to use the original functionality for IE base.Process(args); return; } Assert.ArgumentNotNull((object)args, "args"); if (!args.CloseDialogOnEnd) return; string str1 = args.Parameters["message"]; if (!string.IsNullOrEmpty(str1)) { string str2 = HttpUtility.UrlEncode(args.Properties["filename"] as string ?? string.Empty); HttpContext.Current.Response.Write(string.Format("<html><head><script type='text/JavaScript' language='javascript'>window.top.scForm.browser.getTopModalDialog().frames[0].scForm.postRequest('', '', '', '{0}(filename={1})')</script></head><body>Done</body></html>", (object)str1, (object)str2)); } else HttpContext.Current.Response.Write("<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.browsr.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", \"EndUploading\")</script></head><body>Done</body></html>"); }
/// <summary> /// Runs the processor /// </summary> /// <param name="args"></param> public void Process(UploadArgs args) { foreach (string fileKey in args.Files) { var fileName = args.Files[fileKey]?.FileName; var contentType = args.Files[fileKey]?.ContentType; if (IsFilteredContentType(contentType)) { var file = StringUtil.EscapeJavascriptString(fileName); var reason = StringUtil.EscapeJavascriptString("File upload is restricted."); args.UiResponseHandlerEx.FileCannotBeUploaded(file, reason); args.ErrorText = Translate.Text($"The file \"{fileName}\" cannot be uploaded"); Log.Error(args.ErrorText, this); args.AbortPipeline(); break; } } }
private void UploadToDatabase(string fileName, MemoryStream optimizedImage, UploadArgs args, bool isFileBased) { string validPath = FileUtil.MakePath(args.Folder, Path.GetFileName(fileName), '/'); string validMediaPath = MediaPathManager.ProposeValidMediaPath(validPath); Item createdItem = null; MediaCreatorOptions options = new MediaCreatorOptions() { Versioned = args.Versioned, Language = args.Language, OverwriteExisting = !args.Overwrite, Destination = validMediaPath, FileBased = isFileBased, AlternateText = args.GetFileParameter(fileName, "alt"), Database = null, }; options.Build(GetMediaCreatorOptionsArgs.UploadContext); createdItem = MediaManager.Creator.CreateFromStream(optimizedImage, validPath, options); }
public void Process(UploadArgs args) { var Database = args.UploadedItems.Any() ? args.UploadedItems.First().Database : null; if (Database == null) { return; } foreach (Item mediaItem in args.UploadedItems) { var searchRoot = Database.GetItem(Settings.ImageSearchFolderId); CheckboxField f = searchRoot.Fields[Settings.AnalyzeNewImageField]; if (f == null || !f.Checked) { return; } AnalysisService.AnalyzeImage(mediaItem); } }
public void Process(UploadArgs args) { Assert.ArgumentNotNull(args, "args"); for (int index = 0; index < args.Files.Count; ++index) { HttpPostedFile file1 = args.Files[index]; var alternateText = args.GetFileParameter(file1.FileName, "alt"); if (string.IsNullOrEmpty(alternateText)) { Stream imageStream = new MemoryStream(); file1.InputStream.CopyTo(imageStream); file1.InputStream.Position = imageStream.Position = 0; string alt = AnalyseImage(imageStream).Result; if (!args.Language.ToString().Contains("en")) { alt = TranslateText(alt, args.Language.ToString()).Result; } args.SetFileParameter(file1.FileName, "alt", alt); } Log.Info("media upload alt=" + alternateText, this); } }
private void UnpackToDatabase(HttpPostedFile originalFile, UploadArgs args, bool isFileBased) { string str = FileUtil.MapPath(TempFolder.GetFilename("temp.zip")); originalFile.SaveAs(str); try { using (ZipReader zipReader = new ZipReader(str)) { foreach (ZipEntry entry in zipReader.Entries) { if (!entry.IsDirectory) { UploadToDatabase(entry.Name, (MemoryStream)entry.GetStream(), args, isFileBased); } } } } finally { FileUtil.Delete(str); } }
/// <summary> /// Uploads to file. /// </summary> /// <param name="args">The arguments.</param> /// <param name="file">The file.</param> /// <returns> /// The name of the uploaded file /// </returns> private string UploadToFile(UploadArgs args, HttpPostedFile file) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(file, "file"); var str = FileUtil.MakePath(args.Folder, Path.GetFileName(file.FileName), '\\'); if (!args.Overwrite) str = FileUtil.GetUniqueFilename(str); file.SaveAs(str); Log.Info("File has been uploaded: " + str, this); return Assert.ResultNotNull(str); }
/// <summary> /// Processes the item. /// </summary> /// <param name="args">The arguments.</param> /// <param name="mediaItem">The media item.</param> /// <param name="path">The path.</param> private void ProcessItem(UploadArgs args, MediaItem mediaItem, string path) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(mediaItem, "mediaItem"); Assert.ArgumentNotNull(path, "path"); if (args.Destination == UploadDestination.Database) Log.Info("Media Item has been uploaded to database: " + path, this); else Log.Info("Media Item has been uploaded to file system: " + path, this); args.UploadedItems.Add(mediaItem.InnerItem); }