Class DbxUploadStyleBuilder<R,​E,​X extends DbxApiException>

  • Type Parameters:
    R - response type returned by server on request success
    E - error type returned by server on request failure
    X - exception type thrown by server on request failure (wraps error type)
    Direct Known Subclasses:
    AlphaUploadBuilder, UploadBuilder

    public abstract class DbxUploadStyleBuilder<R,​E,​X extends DbxApiException>
    extends java.lang.Object
    The common interface for all builders associated with upload style methods. After setting any optional request parameters, use start() or uploadAndFinish(java.io.InputStream) to initiate the request. Example usage:
    
        // set our optional request parameters
        UploadUploader uploader = client.files.uploadBuilder("/test.txt")
            .autorename(true)
            .mute(true)
            .clientModified(new Date())
            .start();
    
        byte [] data = // ... your data here
        try {
            // set our upload content
            OutputStream out = uploader.getOutputStream();
            out.write(data);
    
            // complete request and get server response
            response = uploader.finish();
        } finally {
            uploader.close();
        }
    
    Same example using the uploadAndFinish(java.io.InputStream) convenience method:
    
        FileInputStream in = new FileInputStream(file);
        try {
            // set our optional request parameters
            response = client.files.uploadBuilder("/test.txt")
                .autorename(true)
                .mute(true)
                .clientModified(new Date())
                .uploadAndFinish(in);
        } finally {
            in.close();
        }
    
    • Constructor Detail

      • DbxUploadStyleBuilder

        public DbxUploadStyleBuilder()
    • Method Detail

      • uploadAndFinish

        public R uploadAndFinish​(java.io.InputStream in)
                          throws X extends DbxApiException,
                                 DbxException,
                                 java.io.IOException
        Convenience method for DbxUploader.uploadAndFinish(InputStream):
        
            builder.start().uploadAndFinish(in);
         
        Parameters:
        in - InputStream containing data to upload
        Returns:
        Response from server
        Throws:
        X - if the server sent an error response for the request
        DbxException - if an error occurs uploading the data or reading the response
        java.io.IOException - if an error occurs reading the input stream.
        X extends DbxApiException
      • uploadAndFinish

        public R uploadAndFinish​(java.io.InputStream in,
                                 long limit)
                          throws X extends DbxApiException,
                                 DbxException,
                                 java.io.IOException
        Convenience method for DbxUploader.uploadAndFinish(InputStream, long):
        
            builder.start().uploadAndFinish(in, limit);
         
        Parameters:
        in - InputStream containing data to upload
        limit - Maximum number of bytes to read from the given InputStream
        Returns:
        Response from server
        Throws:
        X - if the server sent an error response for the request
        DbxException - if an error occurs uploading the data or reading the response
        java.io.IOException - if an error occurs reading the input stream.
        X extends DbxApiException
      • uploadAndFinish

        public R uploadAndFinish​(java.io.InputStream in,
                                 long limit,
                                 IOUtil.ProgressListener progressListener)
                          throws X extends DbxApiException,
                                 DbxException,
                                 java.io.IOException
        Convenience method for DbxUploader.uploadAndFinish(InputStream, long, IOUtil.ProgressListener):
        
            builder.start().uploadAndFinish(in, limit, progressListener);
         
        Parameters:
        in - InputStream containing data to upload
        limit - Maximum number of bytes to read from the given InputStream
        progressListener - ProgressListener to track the upload progress. Only support OKHttpRequester and StandardHttpRequester
        Returns:
        Response from server
        Throws:
        X - if the server sent an error response for the request
        DbxException - if an error occurs uploading the data or reading the response
        java.io.IOException - if an error occurs reading the input stream.
        X extends DbxApiException
      • uploadAndFinish

        public R uploadAndFinish​(java.io.InputStream in,
                                 IOUtil.ProgressListener progressListener)
                          throws X extends DbxApiException,
                                 DbxException,
                                 java.io.IOException
        Convenience method for DbxUploader.uploadAndFinish(InputStream, IOUtil.ProgressListener):
        
            builder.start().uploadAndFinish(in, progressListener);
         
        Parameters:
        in - InputStream containing data to upload
        progressListener - ProgressListener to track the upload progress. Only support OKHttpRequester and StandardHttpRequester
        Returns:
        Response from server
        Throws:
        X - if the server sent an error response for the request
        DbxException - if an error occurs uploading the data or reading the response
        java.io.IOException - if an error occurs reading the input stream.
        X extends DbxApiException