Ejemplo n.º 1
0
 public void Cleanup()
 {
     foreach (var mediaId in mediaList)
     {
         var success = StorageProvider.Delete(mediaId);
         System.Diagnostics.Debug.Print($"Blob with id {mediaId} {(success ? "was" : "was not")} deleted");
     }
 }
Ejemplo n.º 2
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);
        }
        /// <summary>
        /// Deletes media from Cloud storage that was previously associated with item
        /// </summary>
        /// <param name="args"></param>
        public void Process(AttachArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (!args.MediaItem.FileBased)
            {
                return;
            }

            Log.Audit("Deleting '{0}' from Cloud storage".FormatWith(args.MediaItem.FilePath), this);
            cloudStorage.Delete(args.MediaItem);
        }
        /// <summary>
        /// Deletes media from Cloud storage that was previously associated with item
        /// </summary>
        /// <param name="args"></param>
        public void Process(AttachArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (!args.MediaItem.FileBased)
            {
                return;
            }

            _logManager.LogAudit("Deleting '{0}' from Cloud storage".FormatWith(args.MediaItem.FilePath), GetType());

            PipelineHelper.AddContainerNameToArgs(args, GetContainerNameFromFilePath(args.MediaItem.FilePath));
            _cloudStorage.Delete(args.MediaItem);
        }
Ejemplo n.º 5
0
        private void DeleteAzureMediaBlob(Item item)
        {
            if (!item.Paths.IsMediaItem)
            {
                return;
            }

            var media = new MediaItem(item);

            if (media.FileBased)
            {
                _cloudStorage.Delete(item);
            }
        }
 public override bool RemoveBlobStream(Guid blobId, CallContext context)
 {
     return(StorageProvider.Delete(blobId.ToString()));
 }