Search in sources :

Example 1 with UploadSessionStartUploader

use of com.dropbox.core.v2.files.UploadSessionStartUploader in project cyberduck by iterate-ch.

the class DropboxWriteFeature method write.

@Override
public HttpResponseOutputStream<Metadata> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    try {
        final DbxUserFilesRequests files = new DbxUserFilesRequests(session.getClient(file));
        final UploadSessionStartUploader start = files.uploadSessionStart();
        new DefaultStreamCloser().close(start.getOutputStream());
        final String sessionId = start.finish().getSessionId();
        if (log.isDebugEnabled()) {
            log.debug(String.format("Obtained session id %s for upload %s", sessionId, file));
        }
        final UploadSessionAppendV2Uploader uploader = open(files, sessionId, 0L);
        return new SegmentingUploadProxyOutputStream(file, status, files, uploader, sessionId);
    } catch (DbxException ex) {
        throw new DropboxExceptionMappingService().map("Upload failed.", ex, file);
    }
}
Also used : DbxUserFilesRequests(com.dropbox.core.v2.files.DbxUserFilesRequests) UploadSessionAppendV2Uploader(com.dropbox.core.v2.files.UploadSessionAppendV2Uploader) DefaultStreamCloser(ch.cyberduck.core.io.DefaultStreamCloser) UploadSessionStartUploader(com.dropbox.core.v2.files.UploadSessionStartUploader) DbxException(com.dropbox.core.DbxException)

Aggregations

DefaultStreamCloser (ch.cyberduck.core.io.DefaultStreamCloser)1 DbxException (com.dropbox.core.DbxException)1 DbxUserFilesRequests (com.dropbox.core.v2.files.DbxUserFilesRequests)1 UploadSessionAppendV2Uploader (com.dropbox.core.v2.files.UploadSessionAppendV2Uploader)1 UploadSessionStartUploader (com.dropbox.core.v2.files.UploadSessionStartUploader)1