之前写过一个往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. Codeforces Round #181 (Div. 2)

    A. Array 模拟. B. Coach 模拟. C. Beautiful Numbers good number的位和最大不超过\(10^7\),那么只要枚举a或b的个数,然后最多循环7次判断位和 ...

  2. H3C端口状态

  3. linux 重用 short 为 I/O 内存

    short 例子模块, 在存取 I/O 端口前介绍的, 也能用来存取 I/O 内存. 为此, 你必须告 诉它使用 I/O 内存在加载时; 还有, 你需要改变基地址来使它指向你的 I/O 区. 例如, ...

  4. Python3内置函数、各数据类型(int/str/list/dict/set/tuple)的内置方法快速一览表

    Python3内置函数 https://www.runoob.com/python3/python3-built-in-functions.html int https://www.runoob.co ...

  5. 【47.40%】【BZOJ 1875】[SDOI2009]HH去散步

    Time Limit: 20 Sec  Memory Limit: 64 MB Submit: 1363  Solved: 646 [Submit][Status][Discuss] Descript ...

  6. vue-cli 3.0 eslint

    1.关闭eslint module.exports = { configureWebpack: { devtool: 'source-map' }, lintOnSave: false } 2.修改e ...

  7. IdentityServer4 sign-in

    原文地址 Sign-in IdentityServer 代表 user 分配token之前,user必须登录IdentityServer Cookie authentication 使用 cookie ...

  8. Channel 9视频整理【4】

    Eric ShangKuan 目前服務於台灣微軟,擔任技術傳教士 (Technical Evangelist) 一職,網路上常用的 ID 為 ericsk,對於各項開發技術如:Web.Mobile.A ...

  9. 为什么IIS应用程序池回收时间默认被设置为1740分钟?

    作者:斯科特 福赛斯/Scott Forsyth日期:2013/04/06地址:http://weblogs.asp.net/owscott/why-is-the-iis-default-app-po ...

  10. centos7搭建hadoop2.10伪分布模式

    1.准备一台Vmware虚拟机,添加hdfs用户及用户组,配置网络见 https://www.cnblogs.com/qixing/p/11396835.html 在root用户下 添加hdfs用户, ...