Microsoft Azure Storage Explorer(2)
之前写过一个往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)的更多相关文章
- Microsoft Azure Storage Explorer
上周主管说,要把每次开过的发票,要下载成Pdf的文件,然后就实时的将这些发票存到云上面去. 就是这个Microsoft Azure ,微软的亲儿子. 先把代码贴上来吧,挺简单的. ##.链接账号密码 ...
- 推荐一款跨平台的 Azure Storage Explorer
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
- 如何访问Microsoft Azure Storage
首先先要创建存储账户 http://www.cnblogs.com/SignalTips/p/4119128.html 可以通过以下的几个方式访问 通过Visual Studio 2013 Commu ...
- Microsoft Azure Storage Exployer使用指南
概述 Microsoft Azure Storage Exployer 是微软官方推荐的一款管理Azure Storage 客户端工具,客户使用完全免费.支持Windows.Mac和Linux.用户使 ...
- Azure系列2.1 —— com.microsoft.azure.storage.blob
网上azure的资料较少,尤其是API,全是英文的,中文资料更是少之又少.这次由于公司项目需要使用Azure,所以对Azure的一些学习心得做下笔记,文中不正确地方请大家指正. Azure Blob ...
- Microsoft Azure Storage架构分析
Microsoft云存储服务分为两个部分,SQL Azure和Azure Storage.云存储系统的可扩展性和功能不可兼得,必须牺牲一定的关系数据库功能换取可扩展性.Microsoft实现云存储的思 ...
- Azure Queue Storage 基本用法 -- Azure Storage 之 Queue
Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure File Storage 基 ...
- Azure File Storage 基本用法 -- Azure Storage 之 File
Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Blob Storage 基 ...
- Azure Blob Storage 基本用法 -- Azure Storage 之 Blob
Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Table storage ...
随机推荐
- pip安装python包时报字符编码错
比如安装scikit-learn时报错: django ascii’ codec can’t encode character 原因是用户目录或用户名存在中文,ascii不能解码,解决办法是在Pyth ...
- python基础十二之生成器进阶
生成器表达式 (满足条件的元素或其相关的操作 for 元素 in 可迭代对象 if 条件) g = (i for i in range(10)) for i in g: print(i) egg_li ...
- 2018-11-8-WPF-获取下载内容长度
title author date CreateTime categories WPF 获取下载内容长度 lindexi 2018-11-08 20:18:15 +0800 2018-11-08 20 ...
- 【30.43%】【codeforces 746C】Tram
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- js三大框架出现的意义
解决了原始html,css,js的UI与数据状态之间同步的难题,避免了大量的操作DOM代码. 使用了React,Angular和Vue,我们只需要定义一次 UI 界面,不再需要为每个操作编写特定的 U ...
- Leecoder466 Count The Repetitons
Leecoder466 Count The Repetitons 题目大意 定义\([s,n]\)为连续\(n\)个串\(s\)构成的串 现在给定\(s_1,n_1,s_2,n_2\),求最大的\(m ...
- CSS 高度居中方案
实现高度自适应并且上下居中 <div id="wrap"> <div class="box">DemoSeat</div> ...
- 【Linux】grep笔记
Linux grep命令用于查找文件里符合条件的字符串. 参数: -a 或 --text : 不要忽略二进制的数据. -A<显示行数> 或 --after-context=<显示行数 ...
- URL统一资源定位符
URI 是统一资源标识符 URL 是统一资源定位符 ===================================================== 参考链接: 前端学HTTP之URL:ht ...
- Python 序列求和
#基于Python2.7 多数OJ题库的第一题便是A+B,A+B+C此类求和问题,之前初学Python时是这么做的: while True: try: a,b,c=raw_input().split( ...