直接从WCF服务返回Azure Blob流 [英] Returning Azure Blob Stream directly from WCF service

查看:97
本文介绍了直接从WCF服务返回Azure Blob流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望通过WCF将流从Azure Blob存储直接返回到浏览器. 基本上,我有一个REST WCF服务,我希望在文件存储在Azure Blob存储中的同时让用户通过该服务下载文件.

I am looking to return a stream from Azure Blob Storage directly to the browser via WCF. Basically I have a REST WCF service and I am looking to have users download files via the service while the files are stored in Azure Blob storage.

这个问题

从WCF服务中将Azure BLOB作为流返回-我们需要关闭它吗?

它执行我喜欢的操作,但是它首先将整个文件下载到一个新的流中,是否有一种方法可以将Blob流作为WCF的返回流提供给WCF,因此WCF的作用更像是该流的代理?

it does what I like however it downloads the entire file to a new stream first, is there a way to give the blob stream as the return stream from WCF so WCF acts more like a proxy for the stream?

我的问题是大文件(> 10MB),我真的不想从Azure存储下载整个流,然后才能开始将其返回给用户.

My issue is with large files (> 10MB), I really do not want to download the entire stream from Azure storage before I can start returning it to the user.

我这样做的原因是,在允许访问存储在Azure Blob存储中的文件之前,我正在对用户进行一些安全检查,其中一些文件的大小可能最大为1GB.

The reason I am doing it this way is I am doing some security checks on my user before I will allow access to the file that is stored in Azure Blob Storage, also some of the files could be up to 1GB in size.

推荐答案

在WCF用于授权客户端(并检查blob是否仍然存在,等等)的地方,我做过类似的事情.如果一切正常,则WCF服务返回带有共享访问签名的URL-这允许客户端直接从存储访问流.节省了将Blob拉到wcf角色然后从那里进行流传输的交易成本.

I have done something similar where WCF was used to authorize the client (and check the blob still exists and so on). If everything was OK the WCF service returned a URL with a Shared Access Signature - this allowed the client to access the stream directly from storage. Saving the transaction costs of pulling the blob to the wcf role and then streaming from there.

这可能适合您吗?

这篇关于直接从WCF服务返回Azure Blob流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆