之前写过一个往Microsoft Azure Storage Explorer里存储的功能,现在又要把东西给下载下来。

记录一下:

  public string DownFileFromAzure()
{
StorageCredentials storageCredentials = new StorageCredentials(System.Configuration.ConfigurationManager.AppSettings["Blob_AccountName"].ToString(), System.Configuration.ConfigurationManager.AppSettings["Blob_AccountKey"].ToString());
CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, "core.chinacloudapi.cn", true);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference("acsh");//容器 CloudBlockBlob blockBlobs = blobContainer.GetBlockBlobReference("2019/7/1/131JS0E5201907000005");//除了外层的容器外的全路径
string end= blockBlobs.DownloadText();
byte[] ensbyte = new byte[];
blockBlobs.DownloadToByteArray(ensbyte, );
blockBlobs.DownloadToFile(@"E:\DownFromAzure\Open", FileMode.OpenOrCreate);//直接下载到本地的文件
//blockBlobs.Delete(); return "";
}

2.然后,现在要把这个从Azure Blob中下载的文件以流的形式去转成pdf的样子下载出来。

             MemoryStream stream = new MemoryStream();//声明一个流文件,用于接收DownloadToStream();
stream.Seek(,SeekOrigin.Begin);
blockBlobs.DownloadToStream(stream);
byte[] b = stream.ToArray();
//string s = System.Text.Encoding.UTF8.GetString(b, 0, b.Length);
//byte[] fileByte = Convert.FromBase64String(s);
return b;
//blockBlobs.Delete();
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

SECURITY eCURITY = new SECURITY();
byte[] fileByte = eCURITY.DownFileFromAzure();
Response.Clear();
Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.pdf","Test"));
Response.BinaryWrite(fileByte);
Response.ContentType="application/pdf";
Response.Flush();
Response.End();
return View();

在这里一开始,就是遇到超时的情况:其实这个超时是要重写ReadTimeOut的方法,MemoryStream是继承Stream类的。

但是这个length不为0,所以这个是从云上把文件给获取下来了。

因为在前端获取是将byte文件转成流文件的。所以,我在上面的获取流文件的时候,直接将

byte[] b = stream.ToArray();
然后用前端接收下,就把pdf的文件给下载下来l。

Microsoft Azure Storage Explorer(2)的更多相关文章

  1. Microsoft Azure Storage Explorer

    上周主管说,要把每次开过的发票,要下载成Pdf的文件,然后就实时的将这些发票存到云上面去. 就是这个Microsoft Azure ,微软的亲儿子. 先把代码贴上来吧,挺简单的. ##.链接账号密码 ...

  2. 推荐一款跨平台的 Azure Storage Explorer

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

  3. 如何访问Microsoft Azure Storage

    首先先要创建存储账户 http://www.cnblogs.com/SignalTips/p/4119128.html 可以通过以下的几个方式访问 通过Visual Studio 2013 Commu ...

  4. Microsoft Azure Storage Exployer使用指南

    概述 Microsoft Azure Storage Exployer 是微软官方推荐的一款管理Azure Storage 客户端工具,客户使用完全免费.支持Windows.Mac和Linux.用户使 ...

  5. Azure系列2.1 —— com.microsoft.azure.storage.blob

    网上azure的资料较少,尤其是API,全是英文的,中文资料更是少之又少.这次由于公司项目需要使用Azure,所以对Azure的一些学习心得做下笔记,文中不正确地方请大家指正. Azure Blob ...

  6. Microsoft Azure Storage架构分析

    Microsoft云存储服务分为两个部分,SQL Azure和Azure Storage.云存储系统的可扩展性和功能不可兼得,必须牺牲一定的关系数据库功能换取可扩展性.Microsoft实现云存储的思 ...

  7. Azure Queue Storage 基本用法 -- Azure Storage 之 Queue

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure File Storage 基 ...

  8. Azure File Storage 基本用法 -- Azure Storage 之 File

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Blob Storage 基 ...

  9. Azure Blob Storage 基本用法 -- Azure Storage 之 Blob

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Table storage ...

随机推荐

  1. H3C RIP协议概述

  2. linux 使用 jiffies 计数器

    这个计数器和来读取它的实用函数位于 <linux/jiffies.h>, 尽管你会常常只是包含 <linux/sched.h>, 它会自动地将 jiffies.h 拉进来. 不 ...

  3. 关于CPython中set集合的无序研究

    set集合本身是无序的,但是无意间发现set集合中都是数字时set貌似有序了. 无论声明这个set时数字如何摆放,输出结果总是以一种固定的顺序!同样我将dict字典的key值设为int类型,这时候字典 ...

  4. 2019-3-1-C#-double-好用的扩展

    title author date CreateTime categories C# double 好用的扩展 lindexi 2019-3-1 9:19:5 +0800 2018-05-15 10: ...

  5. <QluOJ2018NewCode>计算几何(寄蒜几盒)

    题目描述 现在有一个圆圈,圆圈上有若干个点,请判断能否在若干个点中选择三个点两两相连组成一个等边三角形? 这若干个点在圆圈上按顺时针顺序分布. 如果可以的话输出"Yes"(不含引号 ...

  6. spring boot 实践总结(转)

    pring Boot是最流行的用于开发微服务的Java框架.在本文主要分享的是在专业开发中使用Spring Boot所采用的最佳实践.这些内容是基于个人经验和一些熟知的Spring Boot专家的文章 ...

  7. java中List 和 Set 的区别

    a. 特性 两个接口都是继承自Collection​,是常用来存放数据项的集合,主要区别如下:      ① List和Set之间很重要的一个区别是是否允许重复元素的存在,在List中允许插入重复的元 ...

  8. js中时间戳转换成xxxx-xx-xx xx:xx:xx类型日期格式的做法

    1.十三位数字的时间戳转换方法 var time = new Date(datetime).toLocaleString().replace(/年|月/g, "-").replac ...

  9. Elasticsearch基本概念和使用

    Elasticsearch基本概念和使用 1.操作索引 1.1.基本概念 Elasticsearch也是基于Lucene的全文检索库,本质也是存储数据,很多概念与MySQL类似的. 对比关系: 索引( ...

  10. $Poj1723/AcWing123\ Soldiers$ 排序

    $Poj$ $AcWing$ $Description$ $Sol$ 分别处理$x$坐标和$y$坐标.$y$坐标显然很好处理,就是排个序然后取中位数就好了.$x$没有$y$那么直接叭.所以我首先写了个 ...