/// <summary> /// Saves the editor control value. /// </summary> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void DataEditorControl_OnSave(EventArgs e) { string fileUrl = string.Empty; var postedFile = this.m_Control.PostedFile; if (postedFile != null) { BlobFactory factory = new BlobFactory(m_Control.Options.AccountName, this.m_Control.Options.Key); //Change this to be generic List <string> containers = factory.GetAllContainers().ToList();//get all public containers string containerName; if (containers.Any()) { containerName = containers[0];//select first container in list } else { containerName = "CDN Content"; string publicContainer = factory.CreatePublicContainer(containerName); } //upload file to container and get the url of the file back fileUrl = factory.CreatePublicBlob(containerName, postedFile.FileName, postedFile.InputStream); } // save the value of the control depending on whether a new file is uploaded this.Data.Value = string.IsNullOrEmpty(fileUrl) ? m_Control.FileUrl : fileUrl; }
public override IList <MediaItem> GetMediaItems(string parentId) { var mediaItems = new List <MediaItem>(); EnsureAzureConnection(); if (parentId == "-1") { List <string> containers = _factory.GetAllContainers(); mediaItems.AddRange(containers.Select(container => container.ContainerToMediaItem())); } else { List <string> items = _factory.GetBlobsForContainer(parentId); mediaItems.AddRange(items.Select(item => GetMediaItemWithUrl(_config.CdnDomain, item))); } return(mediaItems); }
/// <summary> /// Saves the editor control value. /// </summary> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void DataEditorControl_OnSave(EventArgs e) { string fileUrl = string.Empty; var postedFile = this.m_Control.PostedFile; if (postedFile != null) { BlobFactory factory = new BlobFactory(m_Control.Options.AccountName, this.m_Control.Options.Key); //Change this to be generic List<string> containers = factory.GetAllContainers().ToList();//get all public containers string containerName; if(containers.Any()) { containerName = containers[0];//select first container in list } else { containerName = "CDN Content"; string publicContainer = factory.CreatePublicContainer(containerName); } //upload file to container and get the url of the file back fileUrl = factory.CreatePublicBlob(containerName, postedFile.FileName, postedFile.InputStream); } // save the value of the control depending on whether a new file is uploaded this.Data.Value = string.IsNullOrEmpty(fileUrl) ? m_Control.FileUrl : fileUrl; }