Returning Azure Blob Stream directly from WCF service

谁说我不能喝 提交于 2019-12-31 00:45:13

问题


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.

In this question

Returning Azure BLOB from WCF service as a Stream - Do we need to close it?

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?

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.

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.


回答1:


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.

Might this work for you?



来源:https://stackoverflow.com/questions/8280047/returning-azure-blob-stream-directly-from-wcf-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!