コード例 #1
0
        public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Log.Debug("Processing file upload to CDN", this);
            var sw = new Stopwatch();

            sw.Start();

            foreach (Item file in args.UploadedItems.Where(file => file.Paths.IsMediaItem))
            {
                /* NOTE: We don't deal with versioned files, should prepend file.Language and file.Version... */

                // delete if previously uploaded
                if (MainUtil.GetBool(file[FieldNameConstants.MediaItem.UploadedToCloud], false))
                {
                    cloudStorage.Delete(file);
                }

                // upload to CDN
                string filename = cloudStorage.Put(file);

                // delete the existing file from disk
                FileUtil.Delete(StringUtil.EnsurePrefix('/', file[FieldNameConstants.MediaItem.FilePath]));

                // update the item file location to CDN
                using (new EditContext(file, SecurityCheck.Disable))
                {
                    file[FieldNameConstants.MediaItem.FilePath]        = filename;
                    file[FieldNameConstants.MediaItem.UploadedToCloud] = "1";
                }
            }

            sw.Stop();
            Log.Debug("File Upload process to CDN complete: " + sw.Elapsed, this);
        }
コード例 #2
0
 /// <summary>
 /// Creates and starts a Sitecore Job to run as a long running background task
 /// </summary>
 /// <param name="args">The UploadArgs</param>
 public void StartMediaProcessorJob(IEnumerable<Item> uploadedItems)
 {
     var args = new MediaProcessorArgs { UploadedItems = uploadedItems };
     var jobOptions = new Sitecore.Jobs.JobOptions("CloudMediaProcessor", "MediaProcessing",
                                                   Sitecore.Context.Site.Name,
                                                   this, "RunMediaProcessor", new object[] { args });
     Sitecore.Jobs.JobManager.Start(jobOptions);
 }
コード例 #3
0
        public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Log.Debug("Generating Thumbnails for uploaded File Based uploads", this);

            var sw = new Stopwatch();

            sw.Start();

            foreach (Item file in args.UploadedItems.Where(file => file.Paths.IsMediaItem))
            {
                var helper = new MediaHelper(file);
                helper.GenerateThumbnail();
            }

            sw.Stop();
            Log.Debug("Finished generating thumbnails: " + sw.Elapsed, this);
        }
コード例 #4
0
        public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Log.Debug("Processing file MD5 calculation", this);

            var sw = new Stopwatch();

            sw.Start();

            foreach (Item file in args.UploadedItems.Where(file => file.Paths.IsMediaItem))
            {
                using (new EditContext(file, SecurityCheck.Disable))
                {
                    var helper = new MediaHelper(file);
                    file[FieldNameConstants.MediaItem.MD5Hash] = helper.CalculateMd5();
                }
            }

            sw.Stop();
            Log.Debug("Finished calculating MD5 hash for files: " + sw.Elapsed, this);
        }
コード例 #5
0
 /// <summary>
 /// Calls Custom Pipeline with the supplied args
 /// </summary>
 /// <param name="args">The UploadArgs</param>
 public void RunMediaProcessor(MediaProcessorArgs args)
 {
     CorePipeline.Run("cloud.MediaProcessor", args);
 }