本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobClient.GetBlobReference方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient.GetBlobReference方法的具体用法?C# CloudBlobClient.GetBlobReference怎么用?C# CloudBlobClient.GetBlobReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.StorageClient.CloudBlobClient
的用法示例。
在下文中一共展示了CloudBlobClient.GetBlobReference方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeletePackageFromBlob
public static void DeletePackageFromBlob(IServiceManagement channel, string storageName, string subscriptionId, Uri packageUri)
{
StorageService storageKeys = channel.GetStorageKeys(subscriptionId, storageName);
string primary = storageKeys.StorageServiceKeys.Primary;
storageKeys = channel.GetStorageService(subscriptionId, storageName);
EndpointList endpoints = storageKeys.StorageServiceProperties.Endpoints;
string str = ((List<string>)endpoints).Find((string p) => p.Contains(".blob."));
StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(storageName, primary);
CloudBlobClient cloudBlobClient = new CloudBlobClient(str, storageCredentialsAccountAndKey);
CloudBlob blobReference = cloudBlobClient.GetBlobReference(packageUri.AbsoluteUri);
blobReference.DeleteIfExists();
}
示例2: RemoveVHD
public static void RemoveVHD(IServiceManagement channel, string subscriptionId, Uri mediaLink)
{
StorageService storageKeys;
char[] chrArray = new char[1];
chrArray[0] = '.';
string str = mediaLink.Host.Split(chrArray)[0];
string components = mediaLink.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)channel))
{
storageKeys = channel.GetStorageKeys(subscriptionId, str);
}
StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(str, storageKeys.StorageServiceKeys.Primary);
CloudBlobClient cloudBlobClient = new CloudBlobClient(components, storageCredentialsAccountAndKey);
CloudBlob blobReference = cloudBlobClient.GetBlobReference(mediaLink.AbsoluteUri);
blobReference.DeleteIfExists();
}
示例3: ProcessDynamicRegisterRequest
private static void ProcessDynamicRegisterRequest(HttpRequest request, HttpResponse response)
{
CloudBlobClient publicClient = new CloudBlobClient("http://theball.blob.core.windows.net/");
string blobPath = GetBlobPath(request);
CloudBlob blob = publicClient.GetBlobReference(blobPath);
response.Clear();
try
{
string template = blob.DownloadText();
string returnUrl = request.Params["ReturnUrl"];
TBRegisterContainer registerContainer = GetRegistrationInfo(returnUrl, request.Url.DnsSafeHost);
string responseContent = RenderWebSupport.RenderTemplateWithContent(template, registerContainer);
response.ContentType = blob.Properties.ContentType;
response.Write(responseContent);
} catch(StorageClientException scEx)
{
response.Write(scEx.ToString());
response.StatusCode = (int)scEx.StatusCode;
} finally
{
response.End();
}
}
示例4: ProcessAnonymousRequest
private void ProcessAnonymousRequest(HttpRequest request, HttpResponse response)
{
CloudBlobClient publicClient = new CloudBlobClient("http://theball.blob.core.windows.net/");
string blobPath = GetBlobPath(request);
CloudBlob blob = publicClient.GetBlobReference(blobPath);
response.Clear();
try
{
blob.FetchAttributes();
response.ContentType = blob.Properties.ContentType;
blob.DownloadToStream(response.OutputStream);
} catch(StorageClientException scEx)
{
if (scEx.ErrorCode == StorageErrorCode.BlobNotFound || scEx.ErrorCode == StorageErrorCode.ResourceNotFound || scEx.ErrorCode == StorageErrorCode.BadRequest)
{
response.Write("Blob not found or bad request: " + blob.Name + " (original path: " + request.Path + ")");
response.StatusCode = (int)scEx.StatusCode;
}
else
{
response.Write("Errorcode: " + scEx.ErrorCode.ToString() + Environment.NewLine);
response.Write(scEx.ToString());
response.StatusCode = (int) scEx.StatusCode;
}
} finally
{
response.End();
}
}
示例5: Translate
public IEnumerable<CloudBlob> Translate(IExpression expression, CloudBlobClient blobClient, MediaFolder mediaFolder)
{
this.Visite(expression);
if (!string.IsNullOrEmpty(fileName))
{
var blob = blobClient.GetBlobReference(mediaFolder.GetMediaFolderItemPath(fileName));
blob.FetchAttributes();
return new[] { blob };
}
else
{
var maxResult = 100;
if (Take.HasValue)
{
maxResult = Take.Value;
}
var take = maxResult;
var skip = 0;
if (Skip.HasValue)
{
skip = Skip.Value;
maxResult = +skip;
}
var blobPrefix = mediaFolder.GetMediaFolderItemPath(prefix);
if (string.IsNullOrEmpty(prefix))
{
blobPrefix += "/";
}
return blobClient.ListBlobsWithPrefixSegmented(blobPrefix, maxResult, null, new BlobRequestOptions() { BlobListingDetails = Microsoft.WindowsAzure.StorageClient.BlobListingDetails.Metadata, UseFlatBlobListing = false })
.Results.Skip(skip).Select(it => it as CloudBlob).Take(take);
}
}
示例6: CreateStorageCrossDomainPolicy
private static void CreateStorageCrossDomainPolicy(CloudBlobClient blobClient)
{
blobClient.GetContainerReference("$root").CreateIfNotExist();
blobClient.GetContainerReference("$root").SetPermissions(
new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
var blob = blobClient.GetBlobReference("clientaccesspolicy.xml");
blob.Properties.ContentType = "text/xml";
blob.UploadText(@"<?xml version=""1.0"" encoding=""utf-8""?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-methods=""*"" http-request-headers=""*"">
<domain uri=""*"" />
<domain uri=""http://*"" />
</allow-from>
<grant-to>
<resource path=""/"" include-subpaths=""true"" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>");
}
示例7: CopyDirectoryToBlob
private void CopyDirectoryToBlob(CloudBlobClient blobClient, string path)
{
var files = Directory.EnumerateFiles(path);
var rootPath = HostingEnvironment.MapPath("~/");
foreach (var file in files) {
var container = file.Substring(rootPath.Length, file.Length - rootPath.Length);
var blobReference = blobClient.GetBlobReference(container);
try {
blobReference.FetchAttributes();
} catch (StorageClientException e) {
if (e.ErrorCode == StorageErrorCode.ResourceNotFound) {
var content = File.ReadAllText(file);
blobReference.UploadText(content);
}
}
}
var directories = Directory.EnumerateDirectories(path);
foreach (var directory in directories) {
CopyDirectoryToBlob(blobClient, directory);
}
}
示例8: DownloadJava
public void DownloadJava(IPaths paths, CloudStorageAccount storageAccount)
{
try
{
var localJavaZipPath = paths.LocalJavaZip;
if (File.Exists(localJavaZipPath))
{
File.Delete(localJavaZipPath);
//return;
}
Trace.TraceInformation("Downloading Java.");
var blobClient = new CloudBlobClient(storageAccount.BlobEndpoint, storageAccount.Credentials);
string blobStoragePath = storageAccount.BlobEndpoint.AbsoluteUri;
string jBlobRelativePath = RoleEnvironment.GetConfigurationSettingValue(ConfigSettings.JavaBlobNameSetting);
string javaBlobAddress = blobStoragePath.CombineUris(jBlobRelativePath);
var blob = blobClient.GetBlobReference(javaBlobAddress);
var option = new BlobRequestOptions();
option.Timeout = new TimeSpan(0, 15, 0);
blob.DownloadToFile(localJavaZipPath, option);
Trace.TraceInformation("Java downloaded.");
}
catch (Exception e)
{
Trace.Fail(string.Format("Error downloading Java: type <{0}> message <{1}> stack trace <{2}>.", e.GetType().FullName, e.Message, e.StackTrace));
throw;
}
}