def http = HttpBuilder.configure {
request.uri = 'http://example.com/download/foo.zip
}
File file = http.get { Download.toTempFile(delegate) }
public class Download
extends java.lang.Object
Helper methods used to assist in downloading remote content.
def http = HttpBuilder.configure {
request.uri = 'http://example.com/download/foo.zip
}
File file = http.get { Download.toTempFile(delegate) }
The example will use a GET request to download the content as a temporary file and return the handle. The delegate property is a reference to the
Closure delegate, which in our case is an instance of HttpConfig.
Any other configuration of the builder must be done in the configure closure.
| Constructor and Description |
|---|
Download() |
| Modifier and Type | Method and Description |
|---|---|
static void |
toFile(HttpConfig config,
java.io.File file)
Downloads the content to a specified file.
|
static void |
toFile(HttpConfig config,
java.lang.String contentType,
java.io.File file)
Downloads the content to a specified file with the specified content type.
|
static void |
toStream(HttpConfig config,
java.io.OutputStream ostream)
Downloads the content into an
OutputStream. |
static void |
toStream(HttpConfig config,
java.lang.String contentType,
java.io.OutputStream ostream)
Downloads the content into an
OutputStream with the specified content type. |
static void |
toTempFile(HttpConfig config)
Downloads the content to a temporary file (*.tmp in the system temp directory).
|
static void |
toTempFile(HttpConfig config,
java.lang.String contentType)
Downloads the content to a temporary file (*.tmp in the system temp directory) with the specified content type.
|
public static void toTempFile(HttpConfig config)
Downloads the content to a temporary file (*.tmp in the system temp directory).
config - the HttpConfig instancepublic static void toTempFile(HttpConfig config, java.lang.String contentType)
Downloads the content to a temporary file (*.tmp in the system temp directory) with the specified content type.
config - the HttpConfig instancecontentType - the content typepublic static void toFile(HttpConfig config, java.io.File file)
Downloads the content to a specified file.
config - the HttpConfig instancefile - the file where content will be downloadedpublic static void toFile(HttpConfig config, java.lang.String contentType, java.io.File file)
Downloads the content to a specified file with the specified content type.
config - the HttpConfig instancefile - the file where content will be downloadedcontentType - the content typepublic static void toStream(HttpConfig config, java.io.OutputStream ostream)
Downloads the content into an OutputStream.
config - the HttpConfig instanceostream - the OutputStream to contain the content.public static void toStream(HttpConfig config, java.lang.String contentType, java.io.OutputStream ostream)
Downloads the content into an OutputStream with the specified content type.
config - the HttpConfig instanceostream - the OutputStream to contain the content.contentType - the content type