Package com.dropbox.core.v2
Class DbxUploadStyleBuilder<R,E,X extends DbxApiException>
java.lang.Object
com.dropbox.core.v2.DbxUploadStyleBuilder<R,E,X>
- Type Parameters:
R- response type returned by server on request successE- error type returned by server on request failureX- exception type thrown by server on request failure (wraps error type)
- Direct Known Subclasses:
AlphaUploadBuilder,UploadBuilder,UploadSessionAppendV2Builder,UploadSessionStartBuilder
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract DbxUploader<R, E, X> start()Begins the upload request using this builder's request parameters and returns aDbxUploaderfor writing the request body.Convenience method forDbxUploader.uploadAndFinish(InputStream):uploadAndFinish(InputStream in, long limit) Convenience method forDbxUploader.uploadAndFinish(InputStream, long):uploadAndFinish(InputStream in, long limit, IOUtil.ProgressListener progressListener) Convenience method forDbxUploader.uploadAndFinish(InputStream, long, IOUtil.ProgressListener):uploadAndFinish(InputStream in, IOUtil.ProgressListener progressListener) Convenience method forDbxUploader.uploadAndFinish(InputStream, IOUtil.ProgressListener):
-
Constructor Details
-
DbxUploadStyleBuilder
public DbxUploadStyleBuilder()
-
-
Method Details
-
start
Begins the upload request using this builder's request parameters and returns aDbxUploaderfor writing the request body. Callers can complete the request by writing the upload data to theOutputStreamreturned byDbxUploader.getOutputStream()and receiving the server response usingDbxUploader.finish(). SeeuploadAndFinish(java.io.InputStream)convenience method for a simpler way to complete the request.- Returns:
DbxUploaderused to upload data and complete the request- Throws:
DbxException- if an error occursing initializing the request
-
uploadAndFinish
Convenience method forDbxUploader.uploadAndFinish(InputStream):builder.start().uploadAndFinish(in);- Parameters:
in-InputStreamcontaining data to upload- Returns:
- Response from server
- Throws:
X- if the server sent an error response for the requestDbxException- if an error occurs uploading the data or reading the responseIOException- if an error occurs reading the input stream.
-
uploadAndFinish
Convenience method forDbxUploader.uploadAndFinish(InputStream, long):builder.start().uploadAndFinish(in, limit);- Parameters:
in-InputStreamcontaining data to uploadlimit- Maximum number of bytes to read from the givenInputStream- Returns:
- Response from server
- Throws:
X- if the server sent an error response for the requestDbxException- if an error occurs uploading the data or reading the responseIOException- if an error occurs reading the input stream.
-
uploadAndFinish
public R uploadAndFinish(InputStream in, long limit, IOUtil.ProgressListener progressListener) throws X, DbxException, IOException Convenience method forDbxUploader.uploadAndFinish(InputStream, long, IOUtil.ProgressListener):builder.start().uploadAndFinish(in, limit, progressListener);- Parameters:
in-InputStreamcontaining data to uploadlimit- Maximum number of bytes to read from the givenInputStreamprogressListener-ProgressListenerto track the upload progress. Only support OKHttpRequester and StandardHttpRequester- Returns:
- Response from server
- Throws:
X- if the server sent an error response for the requestDbxException- if an error occurs uploading the data or reading the responseIOException- if an error occurs reading the input stream.
-
uploadAndFinish
public R uploadAndFinish(InputStream in, IOUtil.ProgressListener progressListener) throws X, DbxException, IOException Convenience method forDbxUploader.uploadAndFinish(InputStream, IOUtil.ProgressListener):builder.start().uploadAndFinish(in, progressListener);- Parameters:
in-InputStreamcontaining data to uploadprogressListener-ProgressListenerto track the upload progress. Only support OKHttpRequester and StandardHttpRequester- Returns:
- Response from server
- Throws:
X- if the server sent an error response for the requestDbxException- if an error occurs uploading the data or reading the responseIOException- if an error occurs reading the input stream.
-