ch.cyberduck.core.features.Write.checksum()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中ch.cyberduck.core.features.Write.checksum()方法的一些代码示例,展示了Write.checksum()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Write.checksum()方法的具体详情如下:
包路径:ch.cyberduck.core.features.Write
类名称:Write
方法名:checksum

Write.checksum介绍

暂无

代码示例

代码示例来源:origin: iterate-ch/cyberduck

@Override
public ChecksumCompute checksum(final Path file) {
  try {
    return registry.find(session, file).getFeature(session, Write.class, proxy).checksum(file);
  }
  catch(VaultUnlockCancelException e) {
    return proxy.checksum(file);
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public ChecksumCompute checksum(final Path file) {
  return new CryptoChecksumCompute(proxy.checksum(file), vault);
}

代码示例来源:origin: iterate-ch/cyberduck

@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);
  }
}

代码示例来源: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 Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
    if(containerService.isContainer(folder)) {
      return super.mkdir(folder, region, status);
    }
    else {
      if(Checksum.NONE == status.getChecksum()) {
        status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
      }
      return super.mkdir(folder, region, status);
    }
  }
}

代码示例来源:origin: iterate-ch/cyberduck

switch(session.getSignatureVersion()) {
  case AWS4HMACSHA256:
    status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
    break;

代码示例来源: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 StorageObject upload(final Path file, final Local local, final BandwidthThrottle throttle,
              final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
  final S3Protocol.AuthenticationHeaderSignatureVersion signatureVersion = session.getSignatureVersion();
  switch(signatureVersion) {
    case AWS4HMACSHA256:
      if(Checksum.NONE == status.getChecksum()) {
        status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
      }
      break;
  }
  try {
    return super.upload(file, local, throttle, listener, status, callback);
  }
  catch(InteroperabilityException e) {
    if(!session.getSignatureVersion().equals(signatureVersion)) {
      // Retry if upload fails with Header "x-amz-content-sha256" set to the hex-encoded SHA256 hash of the
      // request payload is required for AWS Version 4 request signing
      return this.upload(file, local, throttle, listener, status, callback);
    }
    throw e;
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public StorageObject upload(final Path file, final Local local, final BandwidthThrottle throttle,
              final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
  if(Checksum.NONE == status.getChecksum()) {
    // The client-side checksum is passed to the BlackPearl gateway by supplying the applicable CRC HTTP header.
    // If this is done, the BlackPearl gateway verifies that the data received matches the checksum provided.
    // End-to-end data protection requires that the client provide the CRC when uploading the object and then
    // verify the CRC after downloading the object at a later time (see Get Object). The BlackPearl gateway also
    // verifies the CRC when reading from physical data stores so the gateway can identify problems before
    // transmitting data to the client.
    status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
  }
  // Make sure file is available in cache
  final List<TransferStatus> chunks = bulk.query(Transfer.Type.upload, file, status);
  StorageObject stored = null;
  for(TransferStatus chunk : chunks) {
    chunk.setChecksum(ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), chunk));
    stored = super.upload(file, local, throttle, listener, chunk, callback);
  }
  return stored;
}

代码示例来源: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

@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 B2UploadPartResponse call() throws BackgroundException {
    if(overall.isCanceled()) {
      throw new ConnectionCanceledException();
    }
    final TransferStatus status = new TransferStatus()
      .length(length)
      .skip(offset);
    status.setHeader(overall.getHeader());
    status.setNonces(overall.getNonces());
    status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
    status.setSegment(true);
    status.setPart(partNumber);
    return (B2UploadPartResponse) B2LargeUploadService.super.upload(file, local, throttle, listener, status, overall, new StreamProgress() {
      @Override
      public void progress(final long bytes) {
        status.progress(bytes);
        // Discard sent bytes in overall progress if there is an error reply for segment.
        overall.progress(bytes);
      }
      @Override
      public void setComplete() {
        status.setComplete();
      }
    }, callback);
  }
}, overall));

代码示例来源:origin: iterate-ch/cyberduck

@Override
  public StorageObject call() throws BackgroundException {
    if(overall.isCanceled()) {
      throw new ConnectionCanceledException();
    }
    final TransferStatus status = new TransferStatus()
      .length(length)
      .skip(offset);
    status.setHeader(overall.getHeader());
    status.setNonces(overall.getNonces());
    status.setChecksum(writer.checksum(segment).compute(local.getInputStream(), status));
    status.setSegment(true);
    return SwiftLargeObjectUploadFeature.super.upload(
      segment, local, throttle, listener, status, overall, new StreamProgress() {
        @Override
        public void progress(final long bytes) {
          status.progress(bytes);
          // Discard sent bytes in overall progress if there is an error reply for segment.
          overall.progress(bytes);
        }
        @Override
        public void setComplete() {
          status.setComplete();
        }
      }, callback);
  }
}, overall));

代码示例来源: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

status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));

代码示例来源:origin: iterate-ch/cyberduck

final ChecksumCompute feature = session.getFeature(Write.class).checksum(file);
if(feature != null) {
  progress.message(MessageFormat.format(LocaleFactory.localizedString("Calculate checksum for {0}", "Status"),

相关文章