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


Java S3Object.getContentLength方法代码示例

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


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

示例1: copy

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public void copy(String srcKey, String dstKey) throws IOException {
  try {
    if(LOG.isDebugEnabled()) {
      LOG.debug("Copying srcKey: " + srcKey + "to dstKey: " + dstKey + "in bucket: " + bucket.getName());
    }
    if (multipartEnabled) {
      S3Object object = s3Service.getObjectDetails(bucket, srcKey, null,
                                                   null, null, null);
      if (multipartCopyBlockSize > 0 &&
          object.getContentLength() > multipartCopyBlockSize) {
        copyLargeFile(object, dstKey);
        return;
      }
    }

    S3Object dstObject = new S3Object(dstKey);
    dstObject.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
    s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(),
        dstObject, false);
  } catch (ServiceException e) {
    handleException(e, srcKey);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:Jets3tNativeFileSystemStore.java

示例2: retrieveMetadata

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public FileMetadata retrieveMetadata(String key) throws IOException {
  try {
    S3Object object = s3Service.getObjectDetails(bucket, key);
    return new FileMetadata(key, object.getContentLength(),
        object.getLastModifiedDate().getTime());
  } catch (S3ServiceException e) {
    // Following is brittle. Is there a better way?
    if (e.getMessage().contains("ResponseCode=404")) {
      return null;
    }
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:17,代码来源:Jets3tNativeFileSystemStore.java

示例3: list

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private PartialListing list(String prefix, String delimiter,
    int maxListingLength, String priorLastKey) throws IOException {
  try {
    if (prefix.length() > 0 && !prefix.endsWith(PATH_DELIMITER)) {
      prefix += PATH_DELIMITER;
    }
    S3ObjectsChunk chunk = s3Service.listObjectsChunked(bucket.getName(),
        prefix, delimiter, maxListingLength, priorLastKey);
    
    FileMetadata[] fileMetadata =
      new FileMetadata[chunk.getObjects().length];
    for (int i = 0; i < fileMetadata.length; i++) {
      S3Object object = chunk.getObjects()[i];
      fileMetadata[i] = new FileMetadata(object.getKey(),
          object.getContentLength(), object.getLastModifiedDate().getTime());
    }
    return new PartialListing(chunk.getPriorLastKey(), fileMetadata,
        chunk.getCommonPrefixes());
  } catch (S3ServiceException e) {
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:26,代码来源:Jets3tNativeFileSystemStore.java

示例4: list

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private PartialListing list(String prefix, String delimiter,
    int maxListingLength, String priorLastKey) throws IOException {
  try {
    if (prefix.length() > 0 && !prefix.endsWith(PATH_DELIMITER)) {
      prefix += PATH_DELIMITER;
    }
    S3ObjectsChunk chunk = s3Service.listObjectsChunked(bucket.getName(),
        prefix, delimiter, maxListingLength, priorLastKey);
    
    FileMetadata[] fileMetadata =
      new FileMetadata[chunk.getObjects().length];
    for (int i = 0; i < fileMetadata.length; i++) {
      S3Object object = chunk.getObjects()[i];
      fileMetadata[i] = new FileMetadata(object.getKey(),
          object.getContentLength(), object.getLastModifiedDate().getTime());
    }
    return new PartialListing(chunk.getPriorLastKey(), fileMetadata,
        chunk.getCommonPrefixes());
  } catch (S3ServiceException e) {
    handleServiceException(e);
    return null; //never returned - keep compiler happy
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:24,代码来源:Jets3tNativeFileSystemStore.java

示例5: copy

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public void copy(String srcKey, String dstKey) throws IOException {
  try {
    if(LOG.isDebugEnabled()) {
      LOG.debug("Copying srcKey: " + srcKey + "to dstKey: " + dstKey + "in bucket: " + bucket.getName());
    }
    if (multipartEnabled) {
      S3Object object = s3Service.getObjectDetails(bucket, srcKey, null,
                                                   null, null, null);
      if (multipartCopyBlockSize > 0 &&
          object.getContentLength() > multipartCopyBlockSize) {
        copyLargeFile(object, dstKey);
        return;
      }
    }
    s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(),
        new S3Object(dstKey), false);
  } catch (ServiceException e) {
    handleServiceException(srcKey, e);
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:22,代码来源:Jets3tNativeFileSystemStore.java

示例6: get

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public byte[] get(String path) {
    try {
        S3Object obj = m_s3service.getObject(BUCKET, path);
        m_logger.trace("GetObject: {}", path);
        inc();
        if(obj == null) return null;
        int len = (int)obj.getContentLength();
        byte[] data = new byte[len];
        int start = 0;
        InputStream is = obj.getDataInputStream();
        while(start < len) {
            start += is.read(data, start, len - start);
        }
        is.close();
        return data;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:QSFT,项目名称:Doradus,代码行数:20,代码来源:AmazonConnection.java

示例7: copyLargeFile

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public void copyLargeFile(S3Object srcObject, String dstKey) throws IOException {
  try {
    long partCount = srcObject.getContentLength() / multipartCopyBlockSize +
        (srcObject.getContentLength() % multipartCopyBlockSize > 0 ? 1 : 0);

    MultipartUpload multipartUpload = s3Service.multipartStartUpload
        (bucket.getName(), dstKey, srcObject.getMetadataMap());

    List<MultipartPart> listedParts = new ArrayList<MultipartPart>();
    for (int i = 0; i < partCount; i++) {
      long byteRangeStart = i * multipartCopyBlockSize;
      long byteLength;
      if (i < partCount - 1) {
        byteLength = multipartCopyBlockSize;
      } else {
        byteLength = srcObject.getContentLength() % multipartCopyBlockSize;
        if (byteLength == 0) {
          byteLength = multipartCopyBlockSize;
        }
      }

      MultipartPart copiedPart = s3Service.multipartUploadPartCopy
          (multipartUpload, i + 1, bucket.getName(), srcObject.getKey(),
           null, null, null, null, byteRangeStart,
           byteRangeStart + byteLength - 1, null);
      listedParts.add(copiedPart);
    }
    
    Collections.reverse(listedParts);
    s3Service.multipartCompleteUpload(multipartUpload, listedParts);
  } catch (ServiceException e) {
    handleException(e, srcObject.getKey());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:Jets3tNativeFileSystemStore.java

示例8: retrieveMetadata

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public FileMetadata retrieveMetadata(String key) throws IOException {
  try {
    S3Object object = s3Service.getObjectDetails(bucket, key);
    return new FileMetadata(key, object.getContentLength(),
        object.getLastModifiedDate().getTime());
  } catch (S3ServiceException e) {
    // Following is brittle. Is there a better way?
    if (e.getMessage().contains("ResponseCode=404")) {
      return null;
    }
    handleServiceException(e);
    return null; //never returned - keep compiler happy
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:16,代码来源:Jets3tNativeFileSystemStore.java

示例9: copyLargeFile

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public void copyLargeFile(S3Object srcObject, String dstKey) throws IOException {
  try {
    long partCount = srcObject.getContentLength() / multipartCopyBlockSize +
        (srcObject.getContentLength() % multipartCopyBlockSize > 0 ? 1 : 0);

    MultipartUpload multipartUpload = s3Service.multipartStartUpload
        (bucket.getName(), dstKey, srcObject.getMetadataMap());

    List<MultipartPart> listedParts = new ArrayList<MultipartPart>();
    for (int i = 0; i < partCount; i++) {
      long byteRangeStart = i * multipartCopyBlockSize;
      long byteLength;
      if (i < partCount - 1) {
        byteLength = multipartCopyBlockSize;
      } else {
        byteLength = srcObject.getContentLength() % multipartCopyBlockSize;
        if (byteLength == 0) {
          byteLength = multipartCopyBlockSize;
        }
      }

      MultipartPart copiedPart = s3Service.multipartUploadPartCopy
          (multipartUpload, i + 1, bucket.getName(), srcObject.getKey(),
           null, null, null, null, byteRangeStart,
           byteRangeStart + byteLength - 1, null);
      listedParts.add(copiedPart);
    }
    
    Collections.reverse(listedParts);
    s3Service.multipartCompleteUpload(multipartUpload, listedParts);
  } catch (ServiceException e) {
    handleServiceException(e);
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:35,代码来源:Jets3tNativeFileSystemStore.java

示例10: prepareForObjectsDownload

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private void prepareForObjectsDownload() {
    // Build map of existing local files.
    Map<String, String> objectKeyToFilepathMap = null;
    try {
        boolean storeEmptyDirectories = Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME)
            .getBoolProperty("uploads.storeEmptyDirectories", true);
        objectKeyToFilepathMap = FileComparer.getInstance()
            .buildObjectKeyToFilepathMap(downloadDirectory.listFiles(), "", storeEmptyDirectories);
    } catch (Exception e) {
        String message = "Unable to review files in targetted download directory";
        log.error(message, e);
        ErrorDialog.showDialog(ownerFrame, this, cockpitLiteProperties.getProperties(), message, e);

        return;
    }

    filesAlreadyInDownloadDirectoryMap = new HashMap();

    // Build map of S3 Objects being downloaded.
    s3DownloadObjectsMap = FileComparer.getInstance()
        .populateObjectMap("", getSelectedObjects());

    // Identify objects that may clash with existing files, or may be directories,
    // and retrieve details for these.
    ArrayList potentialClashingObjects = new ArrayList();
    Set existingFilesObjectKeys = objectKeyToFilepathMap.keySet();
    Iterator objectsIter = s3DownloadObjectsMap.entrySet().iterator();
    while (objectsIter.hasNext()) {
        Map.Entry entry = (Map.Entry) objectsIter.next();
        String objectKey = (String) entry.getKey();
        S3Object object = (S3Object) entry.getValue();

        if (object.getContentLength() == 0 || existingFilesObjectKeys.contains(objectKey)) {
            potentialClashingObjects.add(object);
        }
        if (existingFilesObjectKeys.contains(objectKey)) {
            filesAlreadyInDownloadDirectoryMap.put(
                objectKey, objectKeyToFilepathMap.get(objectKey));
        }
    }

    if (potentialClashingObjects.size() > 0) {
        // Retrieve details of potential clashes.
        final S3Object[] clashingObjects = (S3Object[])
            potentialClashingObjects.toArray(new S3Object[potentialClashingObjects.size()]);
        (new Thread() {
            @Override
            public void run() {
                isDownloadingObjects = true;
                retrieveObjectsDetails(clashingObjects);
            }
        }).start();
    } else {
        compareRemoteAndLocalFiles(filesAlreadyInDownloadDirectoryMap, s3DownloadObjectsMap, false);
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:57,代码来源:CockpitLite.java


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