本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobClient类的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient类的具体用法?C# CloudBlobClient怎么用?C# CloudBlobClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudBlobClient类属于Microsoft.WindowsAzure.StorageClient命名空间,在下文中一共展示了CloudBlobClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
base.Initialize(requestContext);
DataServiceContext context =
new DataServiceContext(CloudStorageAccount.DevelopmentStorageAccount.TableEndpoint.AbsoluteUri,
CloudStorageAccount.DevelopmentStorageAccount.Credentials);
CloudBlobClient blobClient = new CloudBlobClient(CloudStorageAccount.DevelopmentStorageAccount.BlobEndpoint.AbsoluteUri,
CloudStorageAccount.DevelopmentStorageAccount.Credentials);
Services = new ServiceFacade();
Services.Accounts = new AccountService(Services, new AccountServiceImplementor(context));
Services.Groups = new GroupService(Services, new GroupServiceImplementor(context));
Services.Roles = new RoleService(Services, new RoleServiceImplementor(context));
Services.Images = new ImageService(Services, new ImageServiceImplementor(context));
Services.Blobs = new BlobService(Services, new BlobServiceImplementor(blobClient));
if (User.Identity.IsAuthenticated)
Account = Services.Accounts.Get(User.Identity.Name);
else
Account = null;
if (null == Account)
FormsAuthentication.SignOut();
else
{
Account.LastActivityDate = DateTime.Now;
Account.Save();
}
ViewData["Account"] = Account;
}
示例2: AzureOperations
public AzureOperations(string connectionString)
{
CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
client = account.CreateCloudBlobClient();
var container = client.GetContainerReference("$root");
container.CreateIfNotExist();
}
示例3: AzureBlobClient
public AzureBlobClient(Uri endpoint, string accountName, string accountKey, int timeoutInMinutes = 30, int parallelOperationThreadCount = 1)
{
var credentials = new StorageCredentialsAccountAndKey(accountName, accountKey);
blobClient = new CloudBlobClient(endpoint, credentials);
blobClient.Timeout = new TimeSpan(0, timeoutInMinutes, 0);
blobClient.ParallelOperationThreadCount = parallelOperationThreadCount;
}
示例4: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
#if DEBUG
account = CloudStorageAccount.DevelopmentStorageAccount;
#else
account = new CloudStorageAccount(accountAndKey, true);
#endif
tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);
//client = new CloudQueueClient(account.BlobEndpoint.ToString(), account.Credentials);
qclient = account.CreateCloudQueueClient();
q = qclient.GetQueueReference("icd9mapplotrequests");
rows = new List<ICD9MapPlotResultEntry>();
bclient = account.CreateCloudBlobClient();
container = bclient.GetContainerReference("results");
container.CreateIfNotExist();
client = account.CreateCloudTableClient();
client.CreateTableIfNotExist("ICD9MapPlotResult");
client.CreateTableIfNotExist("DoctorDetails");
client.CreateTableIfNotExist("PatientDetails");
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
return base.OnStart();
}
示例5: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(DevConnectionString);
blobClient = storageAccount.CreateCloudBlobClient();
container = blobClient.GetContainerReference(TestContainerName);
container.CreateIfNotExist();
}
示例6: LargeDataExample
public LargeDataExample(String queueName)
{
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
CloudQueueClient cloudQueueClient = cloudStorageAccount.CreateCloudQueueClient();
cloudQueue = cloudQueueClient.GetQueueReference(queueName);
cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
}
示例7: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 100;
//Initialize Indexer
storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));
//Initialize URL Queue
urlQueueClient = storageAccount.CreateCloudQueueClient();
urlQueue = urlQueueClient.GetQueueReference("urlqueue");
if (urlQueue.CreateIfNotExist())
{
//Add first URL to the queue
CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
urlQueue.AddMessage(firstURL);
}
//Initialize Index Queue
indexQueueClient = storageAccount.CreateCloudQueueClient();
indexQueue = indexQueueClient.GetQueueReference("indexqueue");
indexQueue.CreateIfNotExist();
//Initialize Database Blob
databaseClient = storageAccount.CreateCloudBlobClient();
databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
databaseContainer.CreateIfNotExist();
var permission = databaseContainer.GetPermissions();
permission.PublicAccess = BlobContainerPublicAccessType.Container;
databaseContainer.SetPermissions(permission);
return base.OnStart();
}
示例8: SharedAccessSignatureController
public SharedAccessSignatureController(CloudStorageAccount storageAccount)
{
if (storageAccount == null)
throw new ArgumentNullException("storageAccount", Constants.CloudStorageAccountNullArgumentErrorMessage);
this.cloudBlobClient = storageAccount.CreateCloudBlobClient();
}
示例9: AzureStorageProvider
public AzureStorageProvider(CloudStorageAccount storageAccount)
{
cloudStorageAccount = storageAccount;
// Create the blob client
blobStorage = cloudStorageAccount.CreateCloudBlobClient();
}
示例10: BlobHelper
// Constructor - pass in a storage connection string.
public BlobHelper(string connectionString)
{
Account = CloudStorageAccount.Parse(connectionString);
BlobClient = Account.CreateCloudBlobClient();
BlobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);
}
示例11: GetBlobPath
private static string GetBlobPath(HttpRequest request)
{
string hostName = request.Url.DnsSafeHost;
if (hostName == "localdev")
{
hostName = "www.protonit.net";
}
string containerName = hostName.Replace('.', '-');
string currServingFolder = "";
try
{
// "/2013-03-20_08-27-28";
CloudBlobClient publicClient = new CloudBlobClient("http://caloom.blob.core.windows.net/");
string currServingPath = containerName + "/" + RenderWebSupport.CurrentToServeFileName;
var currBlob = publicClient.GetBlockBlobReference(currServingPath);
string currServingData = currBlob.DownloadText();
string[] currServeArr = currServingData.Split(':');
string currActiveFolder = currServeArr[0];
var currOwner = VirtualOwner.FigureOwner(currServeArr[1]);
InformationContext.Current.Owner = currOwner;
currServingFolder = "/" + currActiveFolder;
}
catch
{
}
return containerName + currServingFolder + request.Path;
}
示例12: BlobEntities
public BlobEntities()
{
if (storageInitialized)
{
return;
}
lock (gate)
{
if (storageInitialized)
{
return;
}
// read account configuration settings
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
// create blob container for images
blobStorage = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobStorage.GetContainerReference("productimages");
container.CreateIfNotExist();
// configure container for public access
var permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
storageInitialized = true;
}
}
示例13: Storage
public Storage(CloudStorageAccount account)
{
this.account = account;
fileStorage = account.CreateCloudBlobClient();
/* Initialize file container */
container = fileStorage.GetContainerReference(filesContainer);
container.CreateIfNotExist();
var permissions = container.GetPermissions();
/* Full permissions. From MSDN, Container-level public access. Anonymous clients can
* read blob content and metadata and container metadata, and can list the blobs within the container.
*
* Other alternatives are Blob (can read content but not metadata) and Off (no
* anonymous access).
*/
// permissions.PublicAccess = BlobContainerPublicAccessType.Container;
permissions.PublicAccess = BlobContainerPublicAccessType.Off;
permissions.SharedAccessPolicies.Remove("basic");
permissions.SharedAccessPolicies.Add("basic", new SharedAccessPolicy()
{
});
container.SetPermissions(permissions);
/* Initialize table (for file metadata) */
CloudTableClient.CreateTablesFromModel(
typeof(FileDataContext),
account.TableEndpoint.AbsoluteUri,
account.Credentials);
}
示例14: UploadFile
public static Uri UploadFile(string storageName, string storageKey, string filePath)
{
var baseAddress = string.Format(CultureInfo.InvariantCulture, ConfigurationConstants.BlobEndpointTemplate, storageName);
var credentials = new StorageCredentialsAccountAndKey(storageName, storageKey);
var client = new CloudBlobClient(baseAddress, credentials);
string containerName = "mydeployments";
string blobName = string.Format(
CultureInfo.InvariantCulture,
"{0}_{1}",
DateTime.UtcNow.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture),
Path.GetFileName(filePath));
CloudBlobContainer container = client.GetContainerReference(containerName);
container.CreateIfNotExist();
CloudBlob blob = container.GetBlobReference(blobName);
// blob.UploadFile(filePath);
UploadBlobStream(blob, filePath);
return new Uri(
string.Format(
CultureInfo.InvariantCulture,
"{0}{1}{2}{3}",
client.BaseUri,
containerName,
client.DefaultDelimiter,
blobName));
}
示例15: WorkerRoleLoader
public WorkerRoleLoader()
{
this.LastModified = DateTime.MinValue;
this.storageAccount = CloudStorageAccount.FromConfigurationSetting(DataConfigurationKey);
this.blobStorage = storageAccount.CreateCloudBlobClient();
}