fetch a file from a given url
fetch a file from a given url
simplified api:
fetch(url: URL, target: FSFile, connectTimeoutMS: Int = 0, readTimeoutMS: Int = 0): Try[FSFile]
fetch(url: URL, target: Try[FSFile], connectTimeoutMS: Int = 0, readTimeoutMS: Int = 0): Try[FSFile]
the optional parameters connectTimeoutMS
and readTimeoutMS
are interpreted as milliseconds.
their default values are 0, with means a infinity timeout.
import sclib.io.net._ import sclib.io.fs._ url("http://example.com").flatMap(_.fetch(file("example.com")))
implementation note: a union type is used here to use the function with either a 'FSFile' or a 'Try[FSFile]'. overloading the function - one for 'FSFile' and one for 'Try[FSFile]' is not usable because the use of default parameters.
add the 'fetch' method to a
java.net.URL
instance