本文整理了Java中ch.cyberduck.core.features.Write.write()
方法的一些代码示例,展示了Write.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Write.write()
方法的具体详情如下:
包路径:ch.cyberduck.core.features.Write
类名称:Write
方法名:write
暂无
代码示例来源:origin: iterate-ch/cyberduck
@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);
}
代码示例来源:origin: iterate-ch/cyberduck
@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);
}
代码示例来源:origin: iterate-ch/cyberduck
@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);
}
}
代码示例来源:origin: iterate-ch/cyberduck
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);
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@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();
}
代码示例来源:origin: iterate-ch/cyberduck
@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()));
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
status.setLength(0L);
final StatusOutputStream<StorageObject> out = writer.write(file, status, new DisabledConnectionCallback());
new DefaultStreamCloser().close(out);
final StorageObject metadata = out.getStatus();
return new Path(file.getParent(), file.getName(), file.getType(),
new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata));
}
代码示例来源:origin: iterate-ch/cyberduck
@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));
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
if(containerService.isContainer(folder)) {
final S3BucketCreateService service = new S3BucketCreateService(session);
service.create(folder, StringUtils.isBlank(region) ? PreferencesFactory.get().getProperty("s3.location") : region);
return folder;
}
else {
if(Checksum.NONE == status.getChecksum()) {
status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
}
// Add placeholder object
status.setMime(MIMETYPE);
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
type.add(Path.Type.placeholder);
final StatusOutputStream<StorageObject> out = writer.write(new Path(folder.getParent(), folder.getName(), type,
new PathAttributes(folder.attributes())), status, new DisabledConnectionCallback());
new DefaultStreamCloser().close(out);
final StorageObject metadata = out.getStatus();
return new Path(folder.getParent(), folder.getName(), type,
new S3AttributesFinderFeature(session).toAttributes(metadata));
}
}
代码示例来源:origin: iterate-ch/cyberduck
public StatusOutputStream<Reply> writeEncrypted(final Path encrypted, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
try {
final Cryptor cryptor = vault.getCryptor();
final StatusOutputStream<Reply> out;
if(status.getOffset() == 0) {
out = proxy.write(encrypted,
new TransferStatus(status).length(vault.toCiphertextSize(status.getLength())).withMime(null), callback);
out.write(status.getHeader().array());
}
else {
out = proxy.write(encrypted,
new TransferStatus(status).
length(vault.toCiphertextSize(status.getLength()) - cryptor.fileHeaderCryptor().headerSize()).
skip(vault.toCiphertextSize(status.getOffset())).
withMime(null), callback);
}
return new CryptoOutputStream<Reply>(out, cryptor, cryptor.fileHeaderCryptor().decryptHeader(status.getHeader()),
status.getNonces(), vault.numberOfChunks(status.getOffset()));
}
catch(IOException e) {
throw new DefaultIOExceptionMappingService().map(e);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@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));
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
try {
if(nodeid.isEncrypted(file)) {
nodeid.setFileKey(status);
}
final StatusOutputStream<VersionId> out = writer.write(file, status, new DisabledConnectionCallback());
out.close();
return new Path(file.getParent(), file.getName(), file.getType(),
new PathAttributes(file.attributes()).withVersionId(out.getStatus().id));
}
catch(IOException e) {
throw new DefaultIOExceptionMappingService().map("Cannot create file {0}", e, file);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
InputStream in;
StatusOutputStream out;
in = from.getFeature(Read.class).read(source, new TransferStatus(status), callback);
Write write = to.getFeature(MultipartWrite.class);
if(null == write) {
// Fallback if multipart write is not available
write = to.getFeature(Write.class);
}
out = write.write(target, status, callback);
new StreamCopier(status, status).transfer(in, out);
final Object reply = out.getStatus();
if(reply instanceof VersionId) {
return new Path(target.getParent(), target.getName(), target.getType(),
new PathAttributes(target.attributes()).withVersionId(((VersionId) reply).id));
}
return target;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
try {
final BlobRequestOptions options = new BlobRequestOptions();
if(containerService.isContainer(folder)) {
// Container name must be lower case.
final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(folder).getName());
container.create(options, context);
return new Path(folder.getParent(), folder.getName(), folder.getType(), new AzureAttributesFinderFeature(session, context).find(folder));
}
else {
if(Checksum.NONE == status.getChecksum()) {
status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
}
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
type.add(Path.Type.placeholder);
final Path placeholder = new Path(folder.getParent(), folder.getName(), type,
new PathAttributes(folder.attributes()));
new DefaultStreamCloser().close(writer.write(placeholder, status, new DisabledConnectionCallback()));
return new Path(placeholder.getParent(), placeholder.getName(), placeholder.getType(), new AzureAttributesFinderFeature(session, context).find(placeholder));
}
}
catch(URISyntaxException e) {
throw new NotfoundException(e.getMessage(), e);
}
catch(StorageException e) {
throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder);
}
}
代码示例来源:origin: iterate-ch/cyberduck
public Reply upload(final Path file, final Local local, final BandwidthThrottle throttle,
final StreamListener listener, final TransferStatus status,
final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException {
try {
final Digest digest = this.digest();
// Wrap with digest stream if available
final InputStream in = this.decorate(local.getInputStream(), digest);
final StatusOutputStream<Reply> out = writer.write(file, status, callback);
new StreamCopier(cancel, progress)
.withOffset(status.getOffset())
.withLimit(status.getLength())
.withListener(listener)
.transfer(in, new ThrottledOutputStream(out, throttle));
final Reply response = out.getStatus();
this.post(file, digest, response);
return response;
}
catch(HttpResponseException e) {
throw new HttpResponseExceptionMappingService().map("Upload {0} failed", e, file);
}
catch(IOException e) {
throw new HttpExceptionMappingService().map("Upload {0} failed", e, file);
}
}
代码示例来源:origin: iterate-ch/cyberduck
final StatusOutputStream<BaseB2Response> out = writer.write(folder, status, new DisabledConnectionCallback());
new DefaultStreamCloser().close(out);
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
try {
if(containerService.isContainer(folder)) {
// Create container at top level
session.getClient().createContainer(regionService.lookup(
new SwiftLocationFeature.SwiftRegion(region)), folder.getName());
return new Path(folder.getParent(), folder.getName(), folder.getType(),
new SwiftAttributesFinderFeature(session, regionService).find(folder));
}
else {
status.setMime("application/directory");
status.setLength(0L);
final StatusOutputStream<StorageObject> out = writer.write(folder, status, new DisabledConnectionCallback());
new DefaultStreamCloser().close(out);
final StorageObject metadata = out.getStatus();
return new Path(folder.getParent(), folder.getName(), folder.getType(),
new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata));
}
}
catch(GenericException e) {
throw new SwiftExceptionMappingService().map("Cannot create folder {0}", e, folder);
}
catch(IOException e) {
throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, folder);
}
}
内容来源于网络,如有侵权,请联系作者删除!