@Test public void testSize() throws Exception { final S3Session session = new S3Session(new Host(new S3Protocol())); final S3WriteFeature feature = new S3WriteFeature(session, null, new Find() { @Override public boolean find(final Path file) { return true; } }, new AttributesFinder() { @Override public PathAttributes find(final Path file) { final PathAttributes attributes = new PathAttributes(); attributes.setSize(3L); return attributes; } }); final Write.Append append = feature.append(new Path("/p", EnumSet.of(Path.Type.file)), 0L, PathCache.empty()); assertFalse(append.append); assertTrue(append.override); assertEquals(3L, append.size, 0L); }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("s3.upload.multipart.threshold")) { if(preferences.getBoolean("s3.upload.multipart")) { try { final List<MultipartUpload> upload = multipartService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(MultipartPart completed : multipartService.list(upload.iterator().next())) { size += completed.getSize(); } return new Append(size); } } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e)); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
S3WriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("s3.upload.multipart.threshold")) { if(preferences.getBoolean("s3.upload.multipart")) { try { final List<MultipartUpload> upload = multipartService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(MultipartPart completed : multipartService.list(upload.iterator().next())) { size += completed.getSize(); } return new Append(size); } } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e)); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } }
S3WriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("s3.upload.multipart.threshold")) { if(preferences.getBoolean("s3.upload.multipart")) { try { final List<MultipartUpload> upload = multipartService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(MultipartPart completed : multipartService.list(upload.iterator().next())) { size += completed.getSize(); } return new Append(size); } } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e)); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } S3WriteFeature(final S3Session session);  S3WriteFeature(final S3Session session, final S3MultipartService multipartService);  S3WriteFeature(final S3Session session, final S3MultipartService multipartService,
                          final Find finder, final AttributesFinder attributes); }
S3WriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("s3.upload.multipart.threshold")) { if(preferences.getBoolean("s3.upload.multipart")) { try { final List<MultipartUpload> upload = multipartService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(MultipartPart completed : multipartService.list(upload.iterator().next())) { size += completed.getSize(); } return new Append(size); } } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e)); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } S3WriteFeature(final S3Session session);  S3WriteFeature(final S3Session session, final S3MultipartService multipartService);  S3WriteFeature(final S3Session session, final S3MultipartService multipartService,
                          final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<StorageObject> 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(); @Override ChecksumCompute checksum(final Path file, final TransferStatus status); }
S3WriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("s3.upload.multipart.threshold")) { if(preferences.getBoolean("s3.upload.multipart")) { try { final List<MultipartUpload> upload = multipartService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(MultipartPart completed : multipartService.list(upload.iterator().next())) { size += completed.getSize(); } return new Append(size); } } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e)); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } S3WriteFeature(final S3Session session);  S3WriteFeature(final S3Session session, final S3MultipartService multipartService);  S3WriteFeature(final S3Session session, final S3MultipartService multipartService,
                          final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<StorageObject> 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(); @Override ChecksumCompute checksum(final Path file, final TransferStatus status);  }