如何从blob下载文件?

时间:2012-05-29 10:58:21

标签: c# asp.net .net

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

2 个答案:

答案 0 :(得分:1)

不确定如何在ASPX中执行此操作,但您应添加新页面以供下载

  1. 获取文件字节
  2. 添加标题条目Content-Type: application/octet-stream
  3. 将数据写入文档

答案 1 :(得分:1)

除了Martin Risell-Lilja

下载控制器

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

如果您希望授权用户元标记,或者可能会降低下载自定义选项的速度。