コード例 #1
0
ファイル: CloudStorage.cs プロジェクト: RFL86/Classics
        public CloudStorage(string storageConnectionString, string blobContainer, bool createIfNotExists = true)
        {
            if (string.IsNullOrWhiteSpace(blobContainer))
            {
                throw new Exception("O parâmetro 'blobContainer' não pode ser nulo, vazio ou em branco.");
            }

            if (string.IsNullOrWhiteSpace(storageConnectionString))
            {
                throw new Exception("O parâmetro 'storageConnectionString' não pode ser nulo, vazio ou em branco.");
            }

            if (blobContainer.Any(char.IsUpper))
            {
                throw new Exception("O parâmetro 'storageConnectionString' não pode conter caracteres em caixa alta.");
            }

            StorageAccount = CloudStorageAccount.Parse(storageConnectionString);
            BlobClient     = StorageAccount.CreateCloudBlobClient();
            BlobContainer  = BlobClient.GetContainerReference(blobContainer);

            if (createIfNotExists)
            {
                BlobContainer.CreateIfNotExists();
            }
        }
コード例 #2
0
        public void CreateContainer()
        {
            BlobContainer = _blobClient.GetContainerReference(_catalog);

            // create it if it does not exist
            BlobContainer.CreateIfNotExists();
        }
コード例 #3
0
        protected void SetContainer()
        {
            BlobContainer = BlobClient.GetContainerReference(ContainerName);

            if (CreateIfNotExists)
            {
                BlobContainer.CreateIfNotExists();
            }
        }
コード例 #4
0
 public void Initialize()
 {
     StorageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
     BlobClient     = StorageAccount.CreateCloudBlobClient();
     //TODO: Change to appropriate container name
     BlobContainer = BlobClient.GetContainerReference("mycontainer");
     //BlobContainer = BlobClient.GetContainerReference("pdflobs");
     BlobContainer.CreateIfNotExists();
 }
コード例 #5
0
            private void ClearAllBlobSecrets()
            {
                BlobContainer.CreateIfNotExists();
                var blobs = BlobContainer.ListBlobs(prefix: TestSiteName.ToLowerInvariant(), useFlatBlobListing: true);

                foreach (IListBlobItem blob in blobs)
                {
                    BlobContainer.GetBlockBlobReference(((CloudBlockBlob)blob).Name).DeleteIfExists();
                }
            }
コード例 #6
0
        protected void SetContainer(string containerName)
        {
            ContainerName = containerName;
            BlobContainer = BlobClient.GetContainerReference(containerName);

            if (CreateIfNotExists)
            {
                BlobContainer.CreateIfNotExists();
            }
        }