Class DbxDownloadStyleBuilder<R>

  • Type Parameters:
    R - The return type of the DbxDownloader
    Direct Known Subclasses:
    DbxAppGetThumbnailV2Builder, DbxUserGetThumbnailV2Builder, DocsDownloadBuilder, DownloadBuilder, DownloadZipBuilder, ExportBuilder, 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, use 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();
        }
    
    • Constructor Detail

      • DbxDownloadStyleBuilder

        protected DbxDownloadStyleBuilder()
    • Method Detail

      • 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. If 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.
        Parameters:
        start - index of first byte in range (index starts at 0)
        length - number of bytes to download starting at start
        Returns:
        this builder
        Throws:
        java.lang.IllegalArgumentException - if start or length are negative
      • range

        public DbxDownloadStyleBuilder<R> range​(long start)
        Sets the partial byte range to download. Only bytes from 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.
        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 - if start is negative
      • download

        public R download​(java.io.OutputStream out)
                   throws DbxException,
                          java.io.IOException
        Convenience method for DbxDownloader.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 body
        java.io.IOException - if an error occurs writing the response body to the output stream.