2012-05-29 42 views
0

我需要在page.aspx上下载文件的解决方案。在数据库中,我有一个表'消息'有两个字段:fileMessageNameSystem.String),fileMessageBytesSystem.Byte[])。 我需要从字节获得页面上的实际文件。如何从blob下载文件?

+2

你还没有真正尝试过什么,对吗? – leppie

+0

我尝试'Response'+'MemoryStream'方法。有趣的是,我可以在某个类上的包装器(而不是代码方页面)上下载文件。 –

回答

1

不知道如何做到这一点的ASPX,但你应该下载添加新的页面

  1. 获取文件的字节
  2. 添加头项Content-Type: application/octet-stream
  3. 您的数据写入到文件
1

除了Martin Risell-Lilja

DownloadController i ñ

Function File(id As String) As FileContentResult 
    Dim Icat = New WebClient().DownloadData("https://file.blob.core.windows.net/app/" + id) 
    Return New FileContentResult(Icat, "application/octet-stream") With {.FileDownloadName = "Höbölö"} 
End Function 

对于MemoryStream的

Function File(id As String) As FileStreamResult 
     Dim Icat = New WebClient().DownloadData("https://file.blob.core.windows.net/app/" + id) 
     Dim ms As New MemoryStream(Icat) 
     Return File(ms, "application/octet-stream","Höbölö") 
    End Function 

得到:www.mysite.com/Download/File/bidi.exe

如果要授权用户的元标记或可减缓下载自定义选项。