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 ...
随机推荐
- 【u224】传送机
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 刷完牙洗完脸,黄黄同学就要上课去了.可是黄黄同学每次去上课时总喜欢把校园里面的每条路都走一遍,当然,黄 ...
- navicat primium 12免安装版的解决方式
https://blog.csdn.net/wanghailong_qd/article/details/85887825 工具————选项 -----环境 会发现是instantclient_10_ ...
- Eclipse修改控制台字体
步骤:Window-->Preference-->General-->Appearance-->Colors and Fonts-->Basic-->Text Fo ...
- MSBuild 常用参数
本文告诉大家在 MSBuild 里面常用的参数 一般的 msbuild 在编译的时候都会添加很多参数,用法如下 进入对应编译的 sln 或 csproj 文件所在的文件夹,执行下面命名 msbuild ...
- <sUbjeCt>Reverse aAlignment SemInaR
翻译过来就是有关逆序对问题的专题. 因为大胆报名担任学校专题讲师所以跪着也要准备好课件...那什么是逆序对? 逆序对就是序列中ai>aj且i<j的有序对 举个栗子: 其中,5>4,但 ...
- 使用FluentEmail发送outlook邮件
一,邮箱账号相关设置 1,创建outLook邮箱. 2,进入邮箱设置->同步电子邮件->允许设备和应用使用pop 3,设置microsoft账号的应用程序密码->进入安全性页面-&g ...
- vs2019 解决方案加载报错
1. 如图 解决方案: 1.先关闭vs: 2.把C:/Users/<users name>/AppData/Local/Microsoft/VisualStudio/14.0/Compon ...
- linux 如何查找命令的路径(which搜索系统命令,whichis搜索文件)
http://hi.baidu.com/longredhao/item/911356ea2d8bed3687d9deed linux 下,我们常使用 cd ,grep,vi 等命令,有时候我们要查到这 ...
- 安卓APP动态调试(IDA实用攻略)
转自:http://drops.wooyun.org/mobile/5942 0x00 前言 随着智能手机的普及,移动APP已经贯穿到人们生活的各个领域.越来越多的人甚至已经对这些APP应用产生了依赖 ...
- Kafka学习笔记(四)—— API使用
Kafka学习笔记(四)-- API使用 1.Producer API 1.1 消息发送流程 Kafka的Producer发送消息采用的是异步发送的方式.在消息发送的过程中,涉及到了两个线程--mai ...