2012-05-29 39 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

如果要授權用戶的元標記或可減緩下載自定義選項。