@Test(expected = NotfoundException.class) public void testUploadInvalidContainer() throws Exception { final S3ThresholdUploadService m = new S3ThresholdUploadService(session, 5 * 1024L ); final Path container = new Path("nosuchcontainer.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final Local local = new NullLocal(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final TransferStatus status = new TransferStatus().length(5 * 1024L); m.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, null); }
@Override public StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback prompt) throws BackgroundException { if(status.getLength() >= threshold) { if(!preferences.getBoolean("s3.upload.multipart")) { log.warn("Multipart upload is disabled with property s3.upload.multipart"); if(status.getLength() < preferences.getLong("s3.upload.multipart.required.threshold")) { return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } } try { return new S3MultipartUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } catch(NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure using multipart upload %s. Fallback to single upload.", e.getMessage())); } } return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); }
S3ThresholdUploadService implements Upload<StorageObject> { @Override public StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback prompt) throws BackgroundException { if(status.getLength() >= threshold) { if(!preferences.getBoolean("s3.upload.multipart")) { log.warn("Multipart upload is disabled with property s3.upload.multipart"); if(status.getLength() < preferences.getLong("s3.upload.multipart.required.threshold")) { return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } } try { return new S3MultipartUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } catch(NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure using multipart upload %s. Fallback to single upload.", e.getMessage())); } } return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } }
S3ThresholdUploadService implements Upload<StorageObject> { @Override public StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback prompt) throws BackgroundException { if(status.getLength() >= threshold) { if(!preferences.getBoolean("s3.upload.multipart")) { log.warn("Multipart upload is disabled with property s3.upload.multipart"); if(status.getLength() < preferences.getLong("s3.upload.multipart.required.threshold")) { return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } } try { return new S3MultipartUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } catch(NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure using multipart upload %s. Fallback to single upload.", e.getMessage())); } } return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } S3ThresholdUploadService(final S3Session session);  S3ThresholdUploadService(final S3Session session, final Long threshold); }
S3ThresholdUploadService implements Upload<StorageObject> { @Override public StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback prompt) throws BackgroundException { if(status.getLength() >= threshold) { if(!preferences.getBoolean("s3.upload.multipart")) { log.warn("Multipart upload is disabled with property s3.upload.multipart"); if(status.getLength() < preferences.getLong("s3.upload.multipart.required.threshold")) { return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } } try { return new S3MultipartUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } catch(NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure using multipart upload %s. Fallback to single upload.", e.getMessage())); } } return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } S3ThresholdUploadService(final S3Session session);  S3ThresholdUploadService(final S3Session session, final Long threshold); @Override Write.Append append(final Path file, final Long length, final Cache<Path> cache); @Override StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener,
                                final TransferStatus status, final ConnectionCallback prompt); @Override Upload<StorageObject> withWriter(final Write<StorageObject> writer); }
S3ThresholdUploadService implements Upload<StorageObject> { @Override public StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback prompt) throws BackgroundException { if(status.getLength() >= threshold) { if(!preferences.getBoolean("s3.upload.multipart")) { log.warn("Multipart upload is disabled with property s3.upload.multipart"); if(status.getLength() < preferences.getLong("s3.upload.multipart.required.threshold")) { return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } } try { return new S3MultipartUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } catch(NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure using multipart upload %s. Fallback to single upload.", e.getMessage())); } } return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt); } S3ThresholdUploadService(final S3Session session);  S3ThresholdUploadService(final S3Session session, final Long threshold); @Override Write.Append append(final Path file, final Long length, final Cache<Path> cache); @Override StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener,
                                final TransferStatus status, final ConnectionCallback prompt); @Override Upload<StorageObject> withWriter(final Write<StorageObject> writer);  }