本文整理汇总了C#中Microsoft.WindowsAzure.CloudStorageAccount.GetBlobDirectoryReference方法的典型用法代码示例。如果您正苦于以下问题:C# CloudStorageAccount.GetBlobDirectoryReference方法的具体用法?C# CloudStorageAccount.GetBlobDirectoryReference怎么用?C# CloudStorageAccount.GetBlobDirectoryReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.CloudStorageAccount
的用法示例。
在下文中一共展示了CloudStorageAccount.GetBlobDirectoryReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformPublish
public override void PerformPublish(string rootPath, string[] filesToPublish)
{
if (string.IsNullOrEmpty(data.AccountName) || string.IsNullOrEmpty(data.AccountKey) || string.IsNullOrEmpty(data.BlobPath))
{
PublishingHost.ShowMessageBox("You need to enter your Windows Azure storage account information before proceeding", MessageBoxButton.OK, MessageBoxImage.Exclamation);
return;
}
cancelled = false;
var blobs = new CloudStorageAccount(new StorageCredentialsAccountAndKey(data.AccountName, data.AccountKey), true).CreateCloudBlobClient();
CreateClientAccessPolicy(blobs);
var directory = blobs.GetBlobDirectoryReference(data.BlobPath);
if (directory.Container.CreateIfNotExist())
{
directory.Container.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
}
int count = 0;
var files = Directory.EnumerateFiles(rootPath).ToList();
Parallel.ForEach(files, (file) =>
{
var blob = directory.GetBlobReference(Path.GetFileName(file));
if (file.Contains(".ismv"))
{
blob.Properties.ContentType = "video/ismv";
}
blob.Properties.CacheControl = "max-age=7200";
blob.UploadFile(file);
OnProgress(string.Format("Uploaded {0} of {1} files", Interlocked.Increment(ref count), files.Count), (double)count/files.Count);
});
}