F# 如何使用FSharp.Data的http模块下载大文件?

F# 如何使用FSharp.Data的http模块下载大文件?,f#,f#-data,F#,F# Data,以下代码段位于FSharp.Data网站中。Text和Binary的类型分别是string和byte[]。将整个2GB文件存储在内存中,然后将其保存到文件中是不好的 let logoUrl = "https://raw.github.com/fsharp/FSharp.Data/master/misc/logo.png" match Http.Request(logoUrl).Body with | Text text -> printfn "Got text content:

以下代码段位于FSharp.Data网站中。
Text
Binary
的类型分别是
string
byte[]
。将整个2GB文件存储在内存中,然后将其保存到文件中是不好的

let logoUrl = "https://raw.github.com/fsharp/FSharp.Data/master/misc/logo.png"
match Http.Request(logoUrl).Body with
| Text text -> 
    printfn "Got text content: %s" text
| Binary bytes -> 
    printfn "Got %d bytes of binary content" bytes.Length

我不认为您可以使用与
FSharp.Data
网站相同的代码来下载大型文件。 我用来下载大文件的是

async {
    let! request = Http.AsyncRequestStream(logoUrl)
    use outputFile = new System.IO.FileStream(fileName,System.IO.FileMode.Create)
    do! request.ResponseStream.CopyToAsync( outputFile ) |> Async.AwaitTaskVoid 
} |> Async.RunSynchronously

如果您想尝试下载无限文件检查(运行风险由您自己承担,它使用的是)

Http.RequestStream(logoUrl.ResponseStream.CopyTo(outStream)
似乎可以。很好,是否需要检查
RequestStream
ResponseStream
返回的
Response
对象是否不为null?考虑到这是一个特定于F的库,我猜这里没有