@Test public void testWrite() throws Exception { final S3MultipartWriteFeature feature = new S3MultipartWriteFeature(session); final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final TransferStatus status = new TransferStatus(); status.setLength(-1L); final Path file = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final HttpResponseOutputStream<VersionId> out = feature.write(file, status, new DisabledConnectionCallback()); final byte[] content = RandomUtils.nextBytes(6 * 1024 * 1024); final ByteArrayInputStream in = new ByteArrayInputStream(content); final TransferStatus progress = new TransferStatus(); new StreamCopier(new TransferStatus(), progress).transfer(in, out); assertEquals(content.length, progress.getOffset()); in.close(); out.close(); assertNotNull(out.getStatus()); assertTrue(new S3FindFeature(session).find(file)); final byte[] compare = new byte[content.length]; final InputStream stream = new S3ReadFeature(session).read(file, new TransferStatus().length(content.length), new DisabledConnectionCallback()); IOUtils.readFully(stream, compare); stream.close(); assertArrayEquals(content, compare); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status); final MultipartUpload multipart; try { multipart = session.getClient().multipartStartUpload( containerService.getContainer(file).getName(), object); if(log.isDebugEnabled()) { log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(), multipart.getUploadId())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Upload {0} failed", e, file); } final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, preferences.getInteger("s3.upload.multipart.size"))) { @Override public VersionId getStatus() { return proxy.getVersionId(); } }; }
S3MultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status); final MultipartUpload multipart; try { multipart = session.getClient().multipartStartUpload( containerService.getContainer(file).getName(), object); if(log.isDebugEnabled()) { log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(), multipart.getUploadId())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Upload {0} failed", e, file); } final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, preferences.getInteger("s3.upload.multipart.size"))) { @Override public VersionId getStatus() { return proxy.getVersionId(); } }; } }
S3MultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status); final MultipartUpload multipart; try { multipart = session.getClient().multipartStartUpload( containerService.getContainer(file).getName(), object); if(log.isDebugEnabled()) { log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(), multipart.getUploadId())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Upload {0} failed", e, file); } final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, preferences.getInteger("s3.upload.multipart.size"))) { @Override public VersionId getStatus() { return proxy.getVersionId(); } }; } S3MultipartWriteFeature(final S3Session session);  S3MultipartWriteFeature(final S3Session session, final Find finder, final AttributesFinder attributes); }
S3MultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status); final MultipartUpload multipart; try { multipart = session.getClient().multipartStartUpload( containerService.getContainer(file).getName(), object); if(log.isDebugEnabled()) { log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(), multipart.getUploadId())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Upload {0} failed", e, file); } final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, preferences.getInteger("s3.upload.multipart.size"))) { @Override public VersionId getStatus() { return proxy.getVersionId(); } }; } S3MultipartWriteFeature(final S3Session session);  S3MultipartWriteFeature(final S3Session session, final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override Append append(final Path file, final Long length, final Cache<Path> cache); @Override boolean temporary(); @Override boolean random(); }
S3MultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status); final MultipartUpload multipart; try { multipart = session.getClient().multipartStartUpload( containerService.getContainer(file).getName(), object); if(log.isDebugEnabled()) { log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(), multipart.getUploadId())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Upload {0} failed", e, file); } final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, preferences.getInteger("s3.upload.multipart.size"))) { @Override public VersionId getStatus() { return proxy.getVersionId(); } }; } S3MultipartWriteFeature(final S3Session session);  S3MultipartWriteFeature(final S3Session session, final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override Append append(final Path file, final Long length, final Cache<Path> cache); @Override boolean temporary(); @Override boolean random();  }