public interface DownloadAction
Download Actions support ETag and OnlyIfModified Http headers. As well as downloading the file to an in-memory String/byte array.
Several implementations of this exist:
OkHttp: OkHttpDownloadAction.
Apache HttpClient: ApacheHttpClientDownloadAction.
Created by covers1624 on 22/11/21.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
DownloadAction.Dest
Interface for consuming the output of an HTTP response.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute()
Execute the download action.
|
DownloadAction.Dest |
getDest() |
DownloadListener |
getDownloadListener() |
boolean |
getOnlyIfModified() |
boolean |
getQuiet() |
java.lang.String |
getUrl() |
boolean |
getUseETag() |
java.lang.String |
getUserAgent() |
boolean |
isUpToDate() |
DownloadAction |
setDest(DownloadAction.Dest dest)
Set the Destination to download content to.
|
DownloadAction |
setDest(java.io.File file)
Set the
File to download content to. |
DownloadAction |
setDest(java.io.OutputStream os)
Set the
OutputStream to download content to. |
DownloadAction |
setDest(java.nio.file.Path path)
Set the
Path to download content to. |
DownloadAction |
setDest(java.io.StringWriter sw)
Set the
StringWriter to download content to. |
DownloadAction |
setDownloadListener(DownloadListener downloadListener)
Set the
DownloadListener to use. |
DownloadAction |
setOnlyIfModified(boolean onlyIfModified)
If this Download action should use
If-Modified-Since
HTTP request header. |
DownloadAction |
setQuiet(boolean quiet)
If this download action should not log things.
|
DownloadAction |
setUrl(java.lang.String url)
Set the URL to download from.
|
DownloadAction |
setUseETag(boolean useETag)
If this download action should use
If-None-Match
HTTP request header. |
DownloadAction |
setUserAgent(java.lang.String userAgent)
Sets the
User-Agent HTTP request header. |
void execute()
throws java.io.IOException
java.io.IOException - If an IO error occurs whilst downloading.HttpResponseException - If the response code was not expected.DownloadAction setUrl(java.lang.String url)
url - The URL.DownloadAction setDest(DownloadAction.Dest dest)
dest - The Destination.DownloadAction setDest(java.io.StringWriter sw)
StringWriter to download content to.sw - The StringWriter.DownloadAction setDest(java.io.OutputStream os)
OutputStream to download content to.os - The OutputStream.DownloadAction setDest(java.io.File file)
File to download content to.file - The file.DownloadAction setDest(java.nio.file.Path path)
Path to download content to.path - The path.DownloadAction setOnlyIfModified(boolean onlyIfModified)
If-Modified-Since
HTTP request header.onlyIfModified - If If-Modified-Since should be used.DownloadAction setUseETag(boolean useETag)
If-None-Match
HTTP request header.useETag - If If-None-Match should be used.DownloadAction setQuiet(boolean quiet)
quiet - If the download action should be quiet.DownloadAction setUserAgent(java.lang.String userAgent)
User-Agent HTTP request header.userAgent - The User-Agent request header.DownloadAction setDownloadListener(DownloadListener downloadListener)
DownloadListener to use.downloadListener - The DownloadListener.java.lang.String getUrl()
DownloadAction.Dest getDest()
boolean getOnlyIfModified()
boolean getUseETag()
boolean getQuiet()
java.lang.String getUserAgent()
DownloadListener getDownloadListener()
boolean isUpToDate()