R
- The return type of the DbxDownloader
public abstract class DbxDownloadStyleBuilder<R> extends Object
start
or download(java.io.OutputStream)
to initiate the request.
Example usage:
// set our optional request parameters
DbxDownloader<FileMetadata> downloader = client.files.getThumbnailBuilder("/test.png")
.format(ThumbnailFormat.png())
.size(ThumbnailSize.w64h64())
.start();
FileMetadata metadata = downloader.getResult();
FileOutputStream out = new FileOutputStream(outFile);
try {
// set our upload content
InputStream in = downloader.getInputStream();
// read from in, write to out
} finally {
downloader.close();
out.close();
}
Same example using the download(java.io.OutputStream)
convenience method:
FileOutputStream out = new FileOutputStream(outFile);
try {
// set our optional request parameters
FileMetadata metadata = client.files.getThumbnailBuilder("/test.png")
.format(ThumbnailFormat.png())
.size(ThumbnailSize.w64h64())
.download(out);
} finally {
out.close();
}
Modifier | Constructor and Description |
---|---|
protected |
DbxDownloadStyleBuilder() |
Modifier and Type | Method and Description |
---|---|
R |
download(OutputStream out)
Convenience method for
DbxDownloader.download(OutputStream) : |
protected List<HttpRequestor.Header> |
getHeaders() |
DbxDownloadStyleBuilder<R> |
range(long start)
Sets the partial byte range to download.
|
DbxDownloadStyleBuilder<R> |
range(long start,
long length)
Sets the partial byte range to download.
|
abstract DbxDownloader<R> |
start()
Issues the download request using this builder's request parameters and returns a
DbxDownloader for reading the response body. |
protected List<HttpRequestor.Header> getHeaders()
public abstract DbxDownloader<R> start() throws DbxException
DbxDownloader
for reading the response body.
Callers should fully read the response body using DbxDownloader.getInputStream()
and
close the downloader afterwards (see DbxDownloader.close()
). This will allow for proper
resource deallocation and connection re-use..
See download(java.io.OutputStream)
convenience method for a simpler way to complete the request.DbxDownloader
used to download data and read the response.DbxException
- if an error occursing issuing the requestpublic DbxDownloadStyleBuilder<R> range(long start, long length)
start
is greater than the length of the content, the range
request will be ignored and server will return the entire contents. If length
extends
beyond the end of the cont`ent, the server will return all bytes from start
until the
end of the content.start
- index of first byte in range (index starts at 0)length
- number of bytes to download starting at start
IllegalArgumentException
- if start
or length
are negativepublic DbxDownloadStyleBuilder<R> range(long start)
start
(inclusive) until the end of the content will be
downloaded. The HTTP Range header will be set for this request. If start
is greater
than the length of the content, the range request will be ignored and server will return the
entire contents.start
- index of first byte in range (index starts at 0). All following bytes in the
content will be downloaded.IllegalArgumentException
- if start
is negativepublic R download(OutputStream out) throws DbxException, IOException
DbxDownloader.download(OutputStream)
:
builder.start().download(out);
out
- OutputStream
to write response body toDbxException
- if an error occurs reading the response or response bodyIOException
- if an error occurs writing the response body to the output stream.