以下代碼片段位於FSharp.Data網站http://fsharp.github.io/FSharp.Data/library/Http.html中。 Text
和Binary
的類型分別是string
和byte[]
。將整個2GB文件存入內存並將其保存到文件並不好。如何使用FSharp.Data的http模塊下載大文件?
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
'Http.RequestStream(logoUrl) .ResponseStream.CopyTo(outStream)'似乎會這樣做。 – Daniel
不錯,它需要檢查RequestStream和ResponseStream的返回'Response'對象是否爲空? – ca9163d9
考慮到這是一個F#特定的庫,我猜不。 – Daniel