当前位置: 首页>>代码示例>>Java>>正文


Java Blob.getSize方法代码示例

本文整理汇总了Java中com.google.cloud.storage.Blob.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java Blob.getSize方法的具体用法?Java Blob.getSize怎么用?Java Blob.getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.cloud.storage.Blob的用法示例。


在下文中一共展示了Blob.getSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isBlobEligible

import com.google.cloud.storage.Blob; //导入方法依赖的package包/类
private boolean isBlobEligible(Blob blob, long minTimeStamp) {
  String blobName = blob.getName();
  String prefixToMatch =  blobName.substring(
      GcsUtil.normalizePrefix(gcsOriginConfig.commonPrefix).length(), blobName.length());
  return blob.getSize() > 0 && blob.getUpdateTime() > minTimeStamp
      && antPathMatcher.match(gcsOriginConfig.prefixPattern, prefixToMatch);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:8,代码来源:GoogleCloudStorageSource.java

示例2: get

import com.google.cloud.storage.Blob; //导入方法依赖的package包/类
@VisibleForTesting
void get(Blob blob, File file) throws IOException, TransferFailedException
{
  final Resource resource = new Resource(blob.getName().substring(getBaseId().getName().length()));
  final long size = blob.getSize();
  try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
    raf.setLength(size);
  }
  fireGetInitiated(resource, file);
  try (
      final ReadChannel readChannel = blob.reader();
      final FileChannel fileChannel = FileChannel.open(
          file.toPath(),
          StandardOpenOption.WRITE,
          StandardOpenOption.READ
      );
  ) {
    fireGetStarted(resource, file);
    final ByteBuffer byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, size);
    long readSize = 0;
    long priorStart = 0;
    do {
      final int mySize = readChannel.read(byteBuffer);
      if (mySize == -1) {
        throw new TransferFailedException(String.format("Premature EOS after [%s] of [%s] bytes", readSize, size));
      }
      readSize += mySize;
      if (priorStart != byteBuffer.position()) {
        final ByteBuffer rob = byteBuffer.duplicate();
        rob.position((int) priorStart).limit(byteBuffer.position());
        final byte[] bytes = ByteBuffer
            .allocate((int) (byteBuffer.position() - priorStart))
            .put(rob)
            .array();
        final TransferEvent event = new TransferEvent(
            this,
            resource,
            TransferEvent.TRANSFER_PROGRESS,
            TransferEvent.REQUEST_GET
        );
        fireTransferProgress(event, bytes, bytes.length);
        priorStart = byteBuffer.position();
      }
    } while (readSize < size);
    fireGetCompleted(resource, file);
    if (LOG.isTraceEnabled()) {
      LOG.trace(String.format("Fetched [%s] bytes for [%s]", readSize, blob));
    }
  }
}
 
开发者ID:drcrallen,项目名称:gswagon-maven-plugin,代码行数:51,代码来源:GSWagon.java

示例3: doGetContentSize

import com.google.cloud.storage.Blob; //导入方法依赖的package包/类
/**
 * Gets the size of the file content
 *
 * @return The file size
 * @throws Exception
 */
@Override protected long doGetContentSize() throws Exception {
  Blob blob = getBlob();
  return blob != null ? blob.getSize() : 0;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:11,代码来源:GoogleCloudStorageFileObject.java


注:本文中的com.google.cloud.storage.Blob.getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。