Class DownloadRequest.Builder
-
- All Implemented Interfaces:
public final class DownloadRequest.Builder
Builder for a DownloadRequest.
-
-
Constructor Summary
Constructors Constructor Description DownloadRequest.Builder(Context context)
Create a builder with default settings.
-
Method Summary
Modifier and Type Method Description DownloadRequest.Builder
uri(@NonNull() Uri uri)
Sets the download source from a Uri. DownloadRequest.Builder
uri(@NonNull() String uri)
Same as uri but parses the given String to a Uri. DownloadRequest.Builder
source(@NonNull() DownloadSource source)
Sets a DownloadSource from which to download. DownloadRequest.Builder
outputFolder(@NonNull() File outputFolder)
Sets the outputFolder
for the download.DownloadRequest.Builder
outputFile(@Nullable() File outputFile)
Sets the outputFile
for the download.DownloadRequest.Builder
overwriteExisting(boolean overwriteExisting)
If set to true
and the outputFile already exists, the download re-download the document.DownloadRequest.Builder
useTemporaryOutputFile(boolean useTemporaryOutputFile)
If set to true
, the download will write to a temporary file with the same path and filename as the output file but append.tmp
to it.DownloadRequest
build()
Create a DownloadRequest from the current settings. -
-
Constructor Detail
-
DownloadRequest.Builder
DownloadRequest.Builder(Context context)
Create a builder with default settings.- Parameters:
context
- Context for resolving resources.
-
-
Method Detail
-
uri
DownloadRequest.Builder uri(@NonNull() Uri uri)
Sets the download source from a Uri.
Valid URI examples:
- Content provider:
content://com.pspdfkit.viewer/documents/demo.pdf
- Asset paths:
file://android_asset/demo.pdf
- Web URLs:
https://www.example.com/demo.pdf
- Parameters:
uri
- Uri of the document to download.
- Content provider:
-
uri
DownloadRequest.Builder uri(@NonNull() String uri)
- Parameters:
uri
- A string representation of a Uri.
-
source
DownloadRequest.Builder source(@NonNull() DownloadSource source)
Sets a DownloadSource from which to download.
- Parameters:
source
- DownloadSource pointing to the PDF document.
-
outputFolder
DownloadRequest.Builder outputFolder(@NonNull() File outputFolder)
Sets the
outputFolder
for the download. When using this method the PDF will use a generated filename derived from the system time. If you want to explicitly specify the output filename use outputFile instead.- Parameters:
outputFolder
- File pointing to the download output directory.
-
outputFile
DownloadRequest.Builder outputFile(@Nullable() File outputFile)
Sets the
outputFile
for the download.- Parameters:
outputFile
- Writable output File for the download.
-
overwriteExisting
DownloadRequest.Builder overwriteExisting(boolean overwriteExisting)
If set to
true
and the outputFile already exists, the download re-download the document. If set tofalse
the download will complete immediately returning the existing file.- Parameters:
overwriteExisting
-true
to re-download in case the output file already exists.
-
useTemporaryOutputFile
DownloadRequest.Builder useTemporaryOutputFile(boolean useTemporaryOutputFile)
If set to
true
, the download will write to a temporary file with the same path and filename as the output file but append.tmp
to it. Iffalse
the download will be written directly into the output file. Defaults totrue
.- Parameters:
useTemporaryOutputFile
-true
to use a temporary output file while downloading, orfalse
to directly write into the ultimate output file.
-
build
DownloadRequest build()
Create a DownloadRequest from the current settings.
- Returns:
An immutable DownloadRequest based on the current builder settings.
-
-
-
-