public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            _logManager.LogDebug("Republishing Media item", GetType());

            RepublishItems(args.UploadedItems);
        }
示例#2
0
        public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            _logManager.LogDebug("Generating Thumbnails for uploaded File Based uploads", GetType());

            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();
            _logManager.LogDebug("Finished generating thumbnails: " + sw.Elapsed, GetType());
        }
示例#3
0
        public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            _logManager.LogDebug("Processing file MD5 calculation", GetType());

            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();
            _logManager.LogDebug("Finished calculating MD5 hash for files: " + sw.Elapsed, GetType());
        }
        public void Process(MediaProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            _logManager.LogDebug("Processing file upload to CDN", GetType());
            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... */

                var containerName = PipelineHelper.GetContainerNameFromArgs(args);

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

                // upload to CDN
                string filename = _cloudStorage.Put(file, containerName);

                // 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();
            _logManager.LogDebug("File Upload process to CDN complete: " + sw.Elapsed, GetType());
        }