@Override public ChecksumCompute checksum(final Path file) { return new CryptoChecksumCompute(proxy.checksum(file), vault); }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { return proxy.append(file, length, cache); }
@Override public boolean random() { return proxy.random(); } }
public void write(final Path file, final byte[] content, final TransferStatus status) throws BackgroundException { final Write<?> write = session._getFeature(Write.class); status.setLength(content.length); status.setChecksum(write.checksum(file).compute(new ByteArrayInputStream(content), status)); final StatusOutputStream<?> out = write.write(file, status, new DisabledConnectionCallback()); try { IOUtils.write(content, out); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } finally { new DefaultStreamCloser().close(out); } } }
@Override public StatusOutputStream<T> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { return registry.find(session, file).getFeature(session, Write.class, proxy).write(file, status, callback); }
@Override public boolean temporary() { return proxy.temporary(); }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(Checksum.NONE == status.getChecksum()) { status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status)); } status.setTimestamp(System.currentTimeMillis()); final StatusOutputStream<BaseB2Response> out = writer.write(file, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); return new Path(file.getParent(), file.getName(), file.getType(), new B2AttributesFinderFeature(session, fileid).toAttributes((B2FileResponse) out.getStatus())); }
@Override public StatusOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(nodeid.isEncrypted(file)) { // File key is set in encryption bulk feature if container is encrypted return new CryptoWriteFeature(session, proxy).write(file, status, callback); } return proxy.write(file, status, callback); }
@Override public boolean temporary() { return proxy.temporary(); }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(Checksum.NONE == status.getChecksum()) { status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status)); } new DefaultStreamCloser().close(writer.write(file, status, new DisabledConnectionCallback())); return new Path(file.getParent(), file.getName(), file.getType(), new AzureAttributesFinderFeature(session, context).find(file)); }
@Override public StatusOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final ObjectReader reader = session.getClient().getJSON().getContext(null).readerFor(FileKey.class); if(log.isDebugEnabled()) { log.debug(String.format("Read file key for file %s", file)); } final FileKey fileKey = reader.readValue(status.getFilekey().array()); return new CryptoOutputStream<VersionId>(session, proxy.write(file, status, callback), Crypto.createFileEncryptionCipher(TripleCryptConverter.toCryptoPlainFileKey(fileKey)), status ); } catch(CryptoSystemException | InvalidFileKeyException e) { throw new CryptoExceptionMappingService().map("Upload {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Upload {0} failed", e, file); } }
@Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { return writer.append(file, length, cache); }
@Override public boolean temporary() { return proxy.temporary(); }
@Override public boolean random() { return proxy.random(); }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(Checksum.NONE == status.getChecksum()) { status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status)); } status.setLength(0L); 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 ChecksumCompute checksum(final Path file) { if(Boolean.valueOf(containerService.getContainer(file).attributes().getCustom().get(SDSAttributesFinderFeature.KEY_ENCRYPTED))) { return new CryptoWriteFeature(session, proxy).checksum(file); } return proxy.checksum(file); } }
@Override public Reply upload(final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final InputStream in = local.getInputStream(); final StatusOutputStream<Reply> out = writer.write(file, status, callback); new StreamCopier(status, status) .withOffset(status.getOffset()) .withLimit(status.getLength()) .withListener(listener) .transfer(in, new ThrottledOutputStream(out, throttle)); return out.getStatus(); }
@Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { return writer.append(file, length, cache); }
@Override public boolean temporary() { return proxy.temporary(); }