/// <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 MediaItem CreateMediaItem(Stream fileStream, string fileName, string contentType, string container) { EnsureAzureConnection(); _factory.CreatePublicBlob(container, fileName, fileStream); return(GetMediaItemById(fileName)); }
/// <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; }