public IBlobStorage Select(BlobStorageType type)
 {
     return((from c in _candidates
             let name = c.GetType().FullName
                        where name.StartsWith(type.ToString())
                        select c).FirstOrDefault());
 }
        public WindowsAzureStorageHelper(string accountName, string accountKey, bool isLocal, string blobEndpointURI, string queueEndpointURI, string tableEndpointURI)
        {
            ContainerName = CONTAINER_NAME;

            StorageAccountInfo = new StorageAccountInfo(new Uri(blobEndpointURI), isLocal, accountName, accountKey);

            BlobStorageType             = BlobStorage.Create(StorageAccountInfo);
            BlobStorageType.RetryPolicy = RetryPolicies.RetryN(2, TimeSpan.FromMilliseconds(100));
            Container = BlobStorageType.GetBlobContainer(ContainerName);

            //Create the container if it does not exist.
            Container.CreateContainer(ContainerMetaData, ContainerAccessControl.Private);

            // Open queue storage.

            //StorageAccountInfo qaccount = StorageAccountInfo.GetDefaultQueueStorageAccountFromConfiguration();

            StorageAccountInfo qaccount = new StorageAccountInfo(new Uri(queueEndpointURI), isLocal, accountName, accountKey);

            QueueStorageType             = QueueStorage.Create(qaccount);
            QueueStorageType             = QueueStorage.Create(qaccount);
            QueueStorageType.RetryPolicy = RetryPolicies.RetryN(2, TimeSpan.FromMilliseconds(100));

            // Open table storage.

            //StorageAccountInfo taccount = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();
            StorageAccountInfo taccount = new StorageAccountInfo(new Uri(tableEndpointURI), isLocal, accountName, accountKey);

            TableStorageType             = TableStorage.Create(taccount);
            TableStorageType             = TableStorage.Create(taccount);
            TableStorageType.RetryPolicy = RetryPolicies.RetryN(2, TimeSpan.FromMilliseconds(100));
        }
示例#3
0
        public bool SetContainerMetadata(string containerName, NameValueCollection metadata)
        {
            CloudBlobContainer container = BlobStorageType.GetContainerReference(containerName);

            container.Metadata.Add(metadata);
            container.SetMetadata();
            return(true);
        }
示例#4
0
        public bool CreateContainer(string containerName, BlobContainerPublicAccessType accessType, NameValueCollection metadata)
        {
            CloudBlobContainer       container = BlobStorageType.GetContainerReference(containerName);
            BlobContainerPermissions perm      = new BlobContainerPermissions();

            perm.PublicAccess = accessType;
            container.SetPermissions(perm);
            container.Metadata.Add(metadata);
            return(container.CreateIfNotExist());
        }
示例#5
0
        public void UpdateBlobMetadata(string containerName, string blobName, BlobProperties blobProperties)
        {
            CloudBlob cb = BlobStorageType.GetContainerReference(containerName).GetBlobReference(blobName);

            cb.Properties.CacheControl    = blobProperties.CacheControl;
            cb.Properties.ContentEncoding = blobProperties.ContentEncoding;
            cb.Properties.ContentMD5      = blobProperties.ContentMD5;
            cb.Properties.ContentType     = blobProperties.ContentType;

            BlobStorageType.GetContainerReference(containerName).GetBlobReference(blobName).SetProperties();
        }
示例#6
0
        private void InitStorage(CloudStorageAccount st)
        {
            // Open blob storage.
            BlobStorageType             = st.CreateCloudBlobClient();
            BlobStorageType.RetryPolicy = RetryPolicies.Retry(2, TimeSpan.FromMilliseconds(100));
            BlobStorageType.GetContainerReference(CONTAINER_NAME).Create();

            // Open queue storage.

            QueueStorageType = st.CreateCloudQueueClient();

            QueueStorageType.RetryPolicy = RetryPolicies.Retry(2, TimeSpan.FromMilliseconds(100));
            QueueStorageType.GetQueueReference("testqueue").CreateIfNotExist();

            // Open table storage.

            TableStorageType             = st.CreateCloudTableClient();
            TableStorageType.RetryPolicy = RetryPolicies.Retry(2, TimeSpan.FromMilliseconds(100));
            TableStorageType.CreateTableIfNotExist("testtable");
        }
        public IEnumerable <object> ListBlobs(string containerName, string prefix, string delimiter, int maxResults, ref string marker)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.ListBlobs(prefix, delimiter, maxResults, ref marker));
        }
        public IEnumerable <object> ListBlobs(string containerName, string prefix)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.ListBlobs(prefix, true));
        }
示例#9
0
 public void GetBlobAsStream(string containerName, string blobName, Stream outputStream)
 {
     BlobStorageType.GetContainerReference(containerName).GetBlobReference(blobName).DownloadToStream(outputStream);
 }
        public bool UpdateBlobMetadataIfNotModified(string containerName, BlobProperties blobProperties)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.UpdateBlobMetadataIfNotModified(blobProperties));
        }
        public bool UpdateBlobIfNotModified(string containerName, BlobProperties cachedBlobProperties, BlobContents blobContents)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.UpdateBlobIfNotModified(cachedBlobProperties, blobContents));
        }
        public bool GetBlobIfModified(string containerName, string blobName, BlobProperties cachedBlobProperties, BlobContents returnedBlobContents, bool transferAsChunks)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.GetBlobIfModified(cachedBlobProperties, returnedBlobContents, transferAsChunks));
        }
        public bool DoesContainerExist(string containerName)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.DoesContainerExist());
        }
        public bool DeleteBlobIfNotModified(string containerName, BlobProperties cachedBlobProperties, string blobName, out bool modified)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.DeleteBlobIfNotModified(cachedBlobProperties, out modified));
        }
        public bool CreateBlob(string containerName, BlobProperties blobProperties, BlobContents blobContents, bool overwrite)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.CreateBlob(blobProperties, blobContents, overwrite));
        }
示例#16
0
 public void GetBlobAsFile(string containerName, string blobName, string outputFileName)
 {
     BlobStorageType.GetContainerReference(containerName).GetBlobReference(blobName).DownloadToFile(outputFileName);
 }
示例#17
0
        public void CopyFromBlob(string sourceContainerName, string sourceBlobName, string destinationContainerName, string destinationBlobName, string versionString)
        {
            CloudBlob source = BlobStorageType.GetContainerReference(sourceContainerName).GetBlobReference(sourceBlobName);

            BlobStorageType.GetContainerReference(destinationContainerName).GetBlobReference(destinationBlobName).CopyFromBlob(source);
        }
示例#18
0
 public BlobProperties GetBlobProperties(string containerName, string blobName)
 {
     return(BlobStorageType.GetContainerReference(containerName).GetBlobReference(blobName).Properties);
 }
        public bool DeleteBlob(string containerName, string blobName)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.DeleteBlob(blobName));
        }
        public bool CreateContainer(string containerName)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.CreateContainer());
        }
        public bool DoesBlobExist(string containerName, string blobName)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.DoesBlobExist(blobName));
        }
        public bool CreateContainer(string containerName, ContainerAccessControl accessType, NameValueCollection metadata)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.CreateContainer(metadata, accessType));
        }
        public BlobProperties GetBlob(string containerName, string blobName, BlobContents returnedBlobContents, bool transferAsChunks)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.GetBlob(blobName, returnedBlobContents, transferAsChunks));
        }
        public ContainerProperties GetContainerProperties(string containerName)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.GetContainerProperties());
        }
        public BlobProperties GetBlobProperties(string containerName, string blobName)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.GetBlobProperties(blobName));
        }
        public bool SetContainerMetadata(string containerName, NameValueCollection metadata)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.SetContainerMetadata(metadata));
        }
        public void UpdateBlobMetadata(string containerName, BlobProperties blobProperties)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            container.UpdateBlobMetadata(blobProperties);
        }
        public ContainerAccessControl GetContainerACL(string containerName)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.GetContainerAccessControl());
        }
        public bool CopyBlob(string containerName, BlobProperties sourceBlobProperties, string sourceBlobName, string destinationBlobName, string versionString)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            return(container.CopyBlob(sourceBlobProperties, sourceBlobName, destinationBlobName, versionString));
        }
        public void SetContainerACL(string containerName, ContainerAccessControl accessType)
        {
            BlobContainer container = BlobStorageType.GetBlobContainer(containerName);

            container.SetContainerAccessControl(accessType);
        }