public S3ThresholdUploadService(final S3Session session, final Long multipartThreshold) { this.session = session; this.multipartThreshold = multipartThreshold; this.writer = new S3WriteFeature(session); }
@Override public HttpResponseOutputStream<StorageObject> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final S3Object object = this.getDetails(file, status); final DelayedHttpEntityCallable<StorageObject> command = new DelayedHttpEntityCallable<StorageObject>() { @Override public StorageObject call(final AbstractHttpEntity entity) throws BackgroundException { try { final RequestEntityRestStorageService client = session.getClient(); client.putObjectWithRequestEntityImpl( containerService.getContainer(file).getName(), object, entity, status.getParameters()); if(log.isDebugEnabled()) { log.debug(String.format("Saved object %s with checksum %s", file, object.getETag())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Upload {0} failed", e, file); } return object; } @Override public long getContentLength() { return status.getLength(); } }; return this.write(file, status, command); }
final S3Object part = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status); try { session.getClient().putObjectWithRequestEntityImpl(
@Override public Path touch(final Path file, final TransferStatus transferStatus) throws BackgroundException { final SpectraBulkService bulk = new SpectraBulkService(session); final TransferStatus status = new TransferStatus(); bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(file), status.length(0L)), new DisabledConnectionCallback()); final StatusOutputStream<StorageObject> out = writer.write(file, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final S3Object metadata = (S3Object) out.getStatus(); return new Path(file.getParent(), file.getName(), file.getType(), new S3AttributesFinderFeature(session).toAttributes(metadata)); }
@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); // ID for the initiated multipart upload. 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.partsize.minimum"))) { @Override public VersionId getStatus() { return proxy.getVersionId(); } }; }
log.info("No pending multipart upload found"); final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status);
public S3TouchFeature(final S3Session session) { this.session = session; this.writer = new S3WriteFeature(session, new S3DisabledMultipartService()); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(source.isFile() || source.isPlaceholder()) { if(null == status.getStorageClass()) { // Keep same storage class status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { // Keep encryption setting status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { // Apply non standard ACL try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e.getDetail())); } } final S3Object destination = new S3WriteFeature(session).getDetails(target, status); destination.setAcl(accessControlListFeature.convert(status.getAcl())); destination.setBucketName(containerService.getContainer(target).getName()); destination.replaceAllMetadata(new HashMap<String, Object>(new S3MetadataFeature(session, accessControlListFeature).getMetadata(source))); final String version = this.copy(source, destination, status); target.attributes().setVersionId(version); } return target; }
return (T) new S3SingleUploadService(this, new S3WriteFeature(this, new S3DisabledMultipartService())); return (T) new S3WriteFeature(this, new S3DisabledMultipartService()); return (T) new GoogleStorageDirectoryFeature(this, new S3WriteFeature(this, new S3DisabledMultipartService()));
return (T) new S3WriteFeature(this); return (T) new S3DirectoryFeature(this, new S3WriteFeature(this, new S3DisabledMultipartService()));