Package com.dropbox.core.v2
Class DbxDownloadStyleBuilder<R>
- java.lang.Object
-
- com.dropbox.core.v2.DbxDownloadStyleBuilder<R>
-
- Type Parameters:
R
- The return type of theDbxDownloader
- Direct Known Subclasses:
DbxAppGetThumbnailV2Builder
,DbxUserGetThumbnailV2Builder
,DocsDownloadBuilder
,DownloadBuilder
,DownloadZipBuilder
,ExportBuilder
,GetContentBuilder
,GetPreviewBuilder
,GetSharedLinkFileBuilder
,GetThumbnailBuilder
public abstract class DbxDownloadStyleBuilder<R> extends java.lang.Object
The common interface for all builders associated with download style methods. After setting any optional request parameters, usestart
ordownload(java.io.OutputStream)
to initiate the request. Example usage:
Same example using the// 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(); }
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(); }
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DbxDownloadStyleBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description R
download(java.io.OutputStream out)
Convenience method forDbxDownloader.download(OutputStream)
:protected java.util.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 aDbxDownloader
for reading the response body.
-
-
-
Method Detail
-
getHeaders
protected java.util.List<HttpRequestor.Header> getHeaders()
-
start
public abstract DbxDownloader<R> start() throws DbxException
Issues the download request using this builder's request parameters and returns aDbxDownloader
for reading the response body. Callers should fully read the response body usingDbxDownloader.getInputStream()
and close the downloader afterwards (seeDbxDownloader.close()
). This will allow for proper resource deallocation and connection re-use.. Seedownload(java.io.OutputStream)
convenience method for a simpler way to complete the request.- Returns:
DbxDownloader
used to download data and read the response.- Throws:
DbxException
- if an error occursing issuing the request
-
range
public DbxDownloadStyleBuilder<R> range(long start, long length)
Sets the partial byte range to download. Only the specified bytes of the content will be downloaded. The HTTP Range header will be set for this request. Ifstart
is greater than the length of the content, the range request will be ignored and server will return the entire contents. Iflength
extends beyond the end of the cont`ent, the server will return all bytes fromstart
until the end of the content.- Parameters:
start
- index of first byte in range (index starts at 0)length
- number of bytes to download starting atstart
- Returns:
- this builder
- Throws:
java.lang.IllegalArgumentException
- ifstart
orlength
are negative
-
range
public DbxDownloadStyleBuilder<R> range(long start)
Sets the partial byte range to download. Only bytes fromstart
(inclusive) until the end of the content will be downloaded. The HTTP Range header will be set for this request. Ifstart
is greater than the length of the content, the range request will be ignored and server will return the entire contents.- Parameters:
start
- index of first byte in range (index starts at 0). All following bytes in the content will be downloaded.- Returns:
- this builder
- Throws:
java.lang.IllegalArgumentException
- ifstart
is negative
-
download
public R download(java.io.OutputStream out) throws DbxException, java.io.IOException
Convenience method forDbxDownloader.download(OutputStream)
:builder.start().download(out);
- Parameters:
out
-OutputStream
to write response body to- Returns:
- Response from server
- Throws:
DbxException
- if an error occurs reading the response or response bodyjava.io.IOException
- if an error occurs writing the response body to the output stream.
-
-