本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlob.DownloadText方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlob.DownloadText方法的具体用法?C# CloudBlob.DownloadText怎么用?C# CloudBlob.DownloadText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.StorageClient.CloudBlob
的用法示例。
在下文中一共展示了CloudBlob.DownloadText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: appendToBlob
private const string MimeTypeName = "text/plain"; // since these are assumed to
#endregion Fields
#region Methods
/// <summary>
/// ugliness of downloading and reuploading whole blob.
/// </summary>
/// <param name="blob"></param>
/// <param name="toAdd"></param>
public static void appendToBlob(CloudBlob blob, string toAdd)
{
string oldLogData = "";
if (Exists(blob))
oldLogData = blob.DownloadText();
blob.DeleteIfExists();
blob.UploadText(oldLogData + "\r\n" + toAdd);
}
示例2: Pygmentize
Tuple<string, IHtmlString> Pygmentize(CloudBlob blob)
{
var filename = Uri.UnescapeDataString(blob.Uri.Segments.Last());
var extension = Path.GetExtension(filename).ToLower();
if (extension == ".mdown")
{
return new Tuple<string, IHtmlString>(null, new MvcHtmlString(new Markdown().Transform(blob.DownloadText())));
}
var formatters = new Dictionary<string, string>()
{
{ ".cscfg", "xml" },
{ ".csdef", "xml" },
{ ".config", "xml" },
{ ".xml", "xml" },
{ ".cmd", "bat" },
{ ".rb", "ruby" },
{ ".cs", "csharp" },
{ ".html", "html" },
{ ".cshtml", "html" },
{ ".css", "css" },
{ ".erb", "erb" },
{ ".haml", "haml" },
{ ".js", "javascript" },
{ ".php", "php" },
{ ".py", "python" },
{ ".yaml", "yaml" },
{ ".yml", "yaml" },
{ ".txt", "text" }
};
var executable = "pygmentize";
if (RoleEnvironment.IsAvailable)
{
executable = Path.Combine(RoleEnvironment.GetLocalResource("Python").RootPath, @"scripts\pygmentize.exe");
}
if (!formatters.ContainsKey(extension))
{
extension = ".txt";
}
var startInfo = new ProcessStartInfo(executable, string.Format("-f html -l {0}", formatters[extension]))
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
};
var proc = Process.Start(startInfo);
proc.StandardInput.Write(blob.DownloadText().Trim(new char[]{'\uFEFF'}));
proc.StandardInput.Close();
return new Tuple<string, IHtmlString>(filename, new MvcHtmlString(proc.StandardOutput.ReadToEnd()));
}
示例3: RenderTemplateWithContentToBlob
public static void RenderTemplateWithContentToBlob(CloudBlob template, CloudBlob renderTarget, InformationSource setAsDefaultSource = null)
{
InformationSourceCollection sources = renderTarget.GetBlobInformationSources();
if(sources == null)
{
sources = CreateDefaultSources(template);
}
if (setAsDefaultSource != null)
{
sources.SetDefaultSource(setAsDefaultSource);
}
string templateContent = template.DownloadText();
List<ContentItem> existingRoots = GetExistingRoots(sources);
string renderResult = RenderTemplateWithContentRoots(templateContent, existingRoots);
bool rerenderRequired = UpdateMismatchedRootsToSources(sources, existingRoots, renderTarget);
renderTarget.SetBlobInformationSources(sources);
renderTarget.UploadBlobText(renderResult, StorageSupport.InformationType_RenderedWebPage);
if(rerenderRequired)
{
RenderTemplateWithContentToBlob(template, renderTarget);
} else
{
sources.SubscribeTargetToSourceChanges(renderTarget);
}
}
示例4: ReadBlobFile
public static string ReadBlobFile(string fileName)
{
// byte[] fileBytes = null;
string fileBytes = string.Empty;
try
{
string storageAccountConnection = string.Empty;
storageAccountConnection = ConfigurationManager.AppSettings["StorageAccount.ConnectionString"].ToString();
// If you want to use Windows Azure cloud storage account, use the following
// code (after uncommenting) instead of the code above.
cloudStorageAccount = CloudStorageAccount.Parse(storageAccountConnection);
// Create the blob client, which provides
// authenticated access to the Blob service.
blobClient = cloudStorageAccount.CreateCloudBlobClient();
string deploymentPackageFolderString = string.Empty;
deploymentPackageFolderString = ConfigurationManager.AppSettings["DeploymentPackageFolder"].ToString();
// Get the container reference.
blobContainer = blobClient.GetContainerReference(deploymentPackageFolderString);
// Create the container if it does not exist.
blobContainer.CreateIfNotExist();
// Set permissions on the container.
containerPermissions = new BlobContainerPermissions();
// This sample sets the container to have public blobs. Your application
// needs may be different. See the documentation for BlobContainerPermissions
// for more information about blob container permissions.
containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;
blobContainer.SetPermissions(containerPermissions);
blob = blobContainer.GetBlobReference(fileName);
BlobRequestOptions blobReqOptions = new BlobRequestOptions();
blobReqOptions.Timeout = new TimeSpan(0, 5, 0);
fileBytes = blob.DownloadText(blobReqOptions);
}
catch (System.Exception ex)
{
Logger.Write(string.Format("Error in ReadBlobFile() Error: {0}", ex.Message));
fileBytes = null;
}
return fileBytes;
}
示例5: DownloadText
private static string DownloadText(CloudBlob blob)
{
return blob.DownloadText();
}