@Test public void testReadInterrupt() throws Exception { final DropboxWriteFeature write = new DropboxWriteFeature(session); final TransferStatus writeStatus = new TransferStatus(); final byte[] content = RandomUtils.nextBytes(66800); writeStatus.setLength(content.length); final Path test = new Path(new DropboxHomeFinderFeature(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final OutputStream out = write.write(test, writeStatus, new DisabledConnectionCallback()); assertNotNull(out); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); final TransferStatus readStatus = new TransferStatus(); { final InputStream in = new DropboxReadFeature(session).read(test, readStatus, new DisabledConnectionCallback()); assertNotNull(in.read()); in.close(); } { final InputStream in = new DropboxReadFeature(session).read(test, readStatus, new DisabledConnectionCallback()); assertNotNull(in); in.close(); } new DropboxDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final DownloadBuilder builder = new DbxUserFilesRequests(session.getClient(file)).downloadBuilder(containerService.getKey(file)); if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); builder.range(range.getStart()); } final DbxDownloader<FileMetadata> downloader = builder.start(); return downloader.getInputStream(); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Download {0} failed", e, file); } }
DropboxReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final DownloadBuilder builder = new DbxUserFilesRequests(session.getClient(file)).downloadBuilder(containerService.getKey(file)); if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); builder.range(range.getStart()); } final DbxDownloader<FileMetadata> downloader = builder.start(); return downloader.getInputStream(); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Download {0} failed", e, file); } } }
DropboxReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final DownloadBuilder builder = new DbxUserFilesRequests(session.getClient(file)).downloadBuilder(containerService.getKey(file)); if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); builder.range(range.getStart()); } final DbxDownloader<FileMetadata> downloader = builder.start(); return downloader.getInputStream(); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Download {0} failed", e, file); } } DropboxReadFeature(final DropboxSession session); }
DropboxReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final DownloadBuilder builder = new DbxUserFilesRequests(session.getClient(file)).downloadBuilder(containerService.getKey(file)); if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); builder.range(range.getStart()); } final DbxDownloader<FileMetadata> downloader = builder.start(); return downloader.getInputStream(); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Download {0} failed", e, file); } } DropboxReadFeature(final DropboxSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(Path file); }
DropboxReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final DownloadBuilder builder = new DbxUserFilesRequests(session.getClient(file)).downloadBuilder(containerService.getKey(file)); if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); builder.range(range.getStart()); } final DbxDownloader<FileMetadata> downloader = builder.start(); return downloader.getInputStream(); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Download {0} failed", e, file); } } DropboxReadFeature(final DropboxSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(Path file);  }