The following code snippet is found in the FSharp.Data website http://fsharp.github.io/FSharp.Data/library/Http.html. The type of Text
and Binary
are string
and byte[]
respectively. It's not good to get the whole 2GB file in memory and then save it to a file.
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